QGenericMatrix Class

template <int N, int M, typename T> class QGenericMatrix

QGenericMatrix 类是一个模板类,用于表示具有 N 列和 M 行的 NxM 变换矩阵。更多

Header: #include <QGenericMatrix>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui

公共函数

QGenericMatrix()
QGenericMatrix(const T *values)
const T *constData() const
void copyDataTo(T *values) const
T *data()
const T *data() const
void fill(T value)
bool isIdentity() const
void setToIdentity()
QGenericMatrix<M, N, T> transposed() const
bool operator!=(const QGenericMatrix<N, M, T> &other) const
T &operator()(int row, int column)
const T &operator()(int row, int column) const
QGenericMatrix<N, M, T> &operator*=(T factor)
QGenericMatrix<N, M, T> &operator+=(const QGenericMatrix<N, M, T> &other)
QGenericMatrix<N, M, T> &operator-=(const QGenericMatrix<N, M, T> &other)
QGenericMatrix<N, M, T> &operator/=(T divisor)
bool operator==(const QGenericMatrix<N, M, T> &other) const
QMatrix2x2
QMatrix2x3
QMatrix2x4
QMatrix3x2
QMatrix3x3
QMatrix3x4
QMatrix4x2
QMatrix4x3
QGenericMatrix<N, M, T> operator*(T factor, const QGenericMatrix<N, M, T> &matrix)
QGenericMatrix<M1, M2, TT> operator*(const QGenericMatrix<NN, M2, TT> &m1, const QGenericMatrix<M1, NN, TT> &m2)
QGenericMatrix<N, M, T> operator*(const QGenericMatrix<N, M, T> &matrix, T factor)
QGenericMatrix<N, M, T> operator+(const QGenericMatrix<N, M, T> &m1, const QGenericMatrix<N, M, T> &m2)
QGenericMatrix<N, M, T> operator-(const QGenericMatrix<N, M, T> &m1, const QGenericMatrix<N, M, T> &m2)
QGenericMatrix<N, M, T> operator-(const QGenericMatrix<N, M, T> &matrix)
QGenericMatrix<N, M, T> operator/(const QGenericMatrix<N, M, T> &matrix, T divisor)
QDataStream &operator<<(QDataStream &stream, const QGenericMatrix<N, M, T> &matrix)
QDataStream &operator>>(QDataStream &stream, QGenericMatrix<N, M, T> &matrix)

详细说明

QGenericMatrix 模板有三个参数:

N列数。
M行数。
T该类用户可见的元素类型。

另请参阅 QMatrix4x4

成员函数文档

QGenericMatrix::QGenericMatrix()

构造一个 NxM 的标识矩阵。

[explicit] QGenericMatrix::QGenericMatrix(const T *values)

根据给定的 N * M 浮点values 构建矩阵。假定数组values 的内容按行列大数顺序排列。

另请参阅 copyDataTo() 。

const T *QGenericMatrix::constData() const

返回指向此矩阵原始数据的常量指针。

另请参见 data()。

void QGenericMatrix::copyDataTo(T *values) const

读取该矩阵中的 N * M 项,并按行-主顺序将其复制到values

T *QGenericMatrix::data()

返回指向此矩阵原始数据的指针。

另请参见 constData()。

const T *QGenericMatrix::data() const

返回指向此矩阵原始数据的常量指针。

另请参见 constData()。

void QGenericMatrix::fill(T value)

value 填充该矩阵的所有元素。

bool QGenericMatrix::isIdentity() const

如果该矩阵是同一矩阵,则返回true ;否则返回 false。

另请参见 setToIdentity().

void QGenericMatrix::setToIdentity()

将此矩阵设置为同一值。

另请参见 isIdentity().

QGenericMatrix<M, N, T> QGenericMatrix::transposed() const

返回该矩阵的对角线转置。

bool QGenericMatrix::operator!=(const QGenericMatrix<N, M, T> &other) const

如果此矩阵与other 不相同,则返回true ;否则返回 false。

T &QGenericMatrix::operator()(int row, int column)

返回该矩阵中位于 (row,column) 位置的元素的引用,以便对该元素进行赋值。

const T &QGenericMatrix::operator()(int row, int column) const

返回该矩阵中位于 (row,column) 位置的元素的常量引用。

QGenericMatrix<N, M, T> &QGenericMatrix::operator*=(T factor)

将该矩阵的所有元素乘以factor

QGenericMatrix<N, M, T> &QGenericMatrix::operator+=(const QGenericMatrix<N, M, T> &other)

other 的内容添加到此矩阵中。

QGenericMatrix<N, M, T> &QGenericMatrix::operator-=(const QGenericMatrix<N, M, T> &other)

从该矩阵中减去other 的内容。

QGenericMatrix<N, M, T> &QGenericMatrix::operator/=(T divisor)

将该矩阵的所有元素除以divisor

bool QGenericMatrix::operator==(const QGenericMatrix<N, M, T> &other) const

如果此矩阵与other 相同,则返回true ;否则返回 false。

相关非成员

QMatrix2x2

QMatrix2x2 类型定义了QGenericMatrix 模板的方便实例化,适用于 2 列 2 行,元素类型为 float。

QMatrix2x3

QMatrix2x3 类型定义了 2 列 3 行、元素类型为 float 的QGenericMatrix 模板的方便实例化。

QMatrix2x4

QMatrix2x4 类型定义了 2 列 4 行、元素类型为 float 的QGenericMatrix 模板的方便实例化。

QMatrix3x2

QMatrix3x2 类型定义了 3 列 2 行、元素类型为 float 的QGenericMatrix 模板的方便实例化。

QMatrix3x3

QMatrix3x3 类型定义了QGenericMatrix 模板的方便实例化,3 列 3 行,元素类型为 float。

QMatrix3x4

QMatrix3x4 类型定义了 3 列 4 行、元素类型为 float 的QGenericMatrix 模板的方便实例化。

QMatrix4x2

QMatrix4x2 类型定义了QGenericMatrix 模板的方便实例化,4 列 2 行,元素类型为 float。

QMatrix4x3

QMatrix4x3 类型定义了QGenericMatrix 模板的方便实例化,4 列 3 行,元素类型为 float。

template <int N, int M, typename T> QGenericMatrix<N, M, T> operator*(T factor, const QGenericMatrix<N, M, T> &matrix)

返回matrix 中所有元素乘以factor 的结果。

template <int NN, int M1, int M2, typename TT> QGenericMatrix<M1, M2, TT> operator*(const QGenericMatrix<NN, M2, TT> &m1, const QGenericMatrix<M1, NN, TT> &m2)

返回 NNxM2 矩阵m1 与 M1xNN 矩阵m2 的乘积,得出 M1xM2 矩阵结果。

template <int N, int M, typename T> QGenericMatrix<N, M, T> operator*(const QGenericMatrix<N, M, T> &matrix, T factor)

返回matrix 中所有元素乘以factor 的结果。

template <int N, int M, typename T> QGenericMatrix<N, M, T> operator+(const QGenericMatrix<N, M, T> &m1, const QGenericMatrix<N, M, T> &m2)

返回m1m2 之和。

template <int N, int M, typename T> QGenericMatrix<N, M, T> operator-(const QGenericMatrix<N, M, T> &m1, const QGenericMatrix<N, M, T> &m2)

返回m1m2 的差值。

template <int N, int M, typename T> QGenericMatrix<N, M, T> operator-(const QGenericMatrix<N, M, T> &matrix)

这是一个重载函数。

返回matrix 的否定值。

template <int N, int M, typename T> QGenericMatrix<N, M, T> operator/(const QGenericMatrix<N, M, T> &matrix, T divisor)

返回matrix 中所有元素除以divisor 的结果。

template <int N, int M, typename T> QDataStream &operator<<(QDataStream &stream, const QGenericMatrix<N, M, T> &matrix)

将给定的matrix 写入给定的stream ,并返回对该数据流的引用。

另请参阅 序列化 Qt 数据类型

template <int N, int M, typename T> QDataStream &operator>>(QDataStream &stream, QGenericMatrix<N, M, T> &matrix)

将一个 NxM 矩阵从给定的stream 读入给定的matrix ,并返回对该数据流的引用。

另请参阅 序列化 Qt 数据类型

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.