Qt cout matrix4x4

时间:2015-02-21 18:55:28

标签: c++ qt cout

我在打印qtmatrix 4x4时遇到问题。

QMatrix4x4 m = ...;
std::cout << m << std::endl;

我收到以下错误

cannot bind 'std::ostream {aka std::basic_ostream<char>}' lvalue 
to 'std::basic_ostream<char>&&'
/usr/include/c++/4.6/ostream:581:5: error:   
initializing argument 1 of 'std::basic_ostream<_CharT, _Traits>& 
std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) 
[with _CharT = char, _Traits = std::char_traits<char>, _Tp = QMatrix4x4]'

Qt Matrix4x4 doc开始,它表明我应该可以输出它。

1 个答案:

答案 0 :(得分:0)

试试这个:

QMatrix4x4 m = ...;
qDebug() << m;

正如您在下面的ostream类文档中所看到的,ostream类不会将流操作符实现为与以下列表不同的类。

ostream& operator<< (bool val);
ostream& operator<< (short val);
ostream& operator<< (unsigned short val);
ostream& operator<< (int val);
ostream& operator<< (unsigned int val);
ostream& operator<< (long val);
ostream& operator<< (unsigned long val);
ostream& operator<< (float val);
ostream& operator<< (double val);
ostream& operator<< (long double val);
ostream& operator<< (void* val);
ostream& operator<< (streambuf* sb );   
ostream& operator<< (ostream& (*pf)(ostream&));
ostream& operator<< (ios& (*pf)(ios&));
ostream& operator<< (ios_base& (*pf)(ios_base&));