如何将QDebug()与QT中的两个参数一起使用
How to use qDebug() with two parameters in qt?
我试图使用两个参数使用qdebug(),但每次都会失败。
当我单独使用时,没有问题,例如;
qDebug() << "img:width = " << img.width();
qDebug() << "img:height = " << img.height();
但是,当我组合它们时,会出现错误。
qDebug() << "img:width = " << img.width() << "/t img:height = " << img.height() << std::endl;
错误是:
error: no match for 'operator<<' in '((QDebug*)((QDebug*)((QDebug*)qDebug()().QDebug::operator<<(((const char*)"img:width = ")))->QDebug::operator<<(img.QImage::width()))->QDebug::operator<<(((const char*)"/t img:height = ")))->QDebug::operator<<(img.QImage::height()) << std::endl'
我可以在qdebug中使用两个或多个参数吗?
编辑::
如果我删除std::endl
删除std :: endl在行末端,std :: endl与std :: cout一起使用,而不是qdebug()
这将有效:
qDebug() << "img:width = " << img.width() << "/t img:height = " << img.height();
我认为您使用/t
而不是t
是问题(我认为您正在尝试在这两个项目之间放置一个选项卡)。再加上,不需要std :: endl。
qDebug() << "img:width = " << img.width() << "t" << "img:height = " << img.height();
或
qDebug() << "img:width = " << img.width() << "t img:height = " << img.height();
应该工作。
相关文章:
- 为什么模板参数推导不适用于仅指定前两个参数的可变参数模板类?
- C++如何在 switch 语句中放置两个参数
- 为什么我不能用两个参数重载 C++ 运算符 []?
- C++添加检查以避免读取两个参数
- 宏的定义从一个值创建两个参数
- C++ 如何使用一个参数从派生类构造函数中调用具有两个参数的超类构造函数
- 通过将两个参数包的元素线程化为类型对来解压缩这两个参数包
- 'int main(int, int, std::__cxx11::string, std::__cxx11::string)'只需要零或两个参数 [-Wmain]
- 错误:函数调用中有两个参数
- Qt 线程两个参数
- 为什么lambda函数用于stl函数,例如sort(),c 中的max_element()函数以两个参数为输入
- 警告:用两个参数构造函数返回对象时,表达结果未使用
- 具有两个参数的 Decltype 修改类型
- 将两个参数传递到谓词remove_if
- 同时扩展两个参数包
- 用两个参数调用新操作员,但没有分配
- 在Variadic模板中交换两个参数
- C CPPUNIT_ASSERT具有两个参数
- 具有两个参数的乘法函数
- 使用一个可选参数获取两个参数到main