Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何在QMessageBox中打印变量值?_C++_Qt_Messagebox_Qmessagebox - Fatal编程技术网

C++ 如何在QMessageBox中打印变量值?

C++ 如何在QMessageBox中打印变量值?,c++,qt,messagebox,qmessagebox,C++,Qt,Messagebox,Qmessagebox,我是否需要先使用QString然后将其放入msgbox?是否有示例?文档中有示例: QMessageBox msgBox; msgBox.setText("Put your text here"); msgBox.exec(); 里面还有一些其他的。请阅读文档。您可以使用以下示例,并可以添加任意数量的参数 int device_count=0; QString status = QString("Found %1 device(s):").arg(device_count); QMessage

我是否需要先使用
QString
然后将其放入msgbox?是否有示例?

文档中有示例:

QMessageBox msgBox;
msgBox.setText("Put your text here");
msgBox.exec();

里面还有一些其他的。请阅读文档。

您可以使用以下示例,并可以添加任意数量的参数

int device_count=0;
QString status = QString("Found %1 device(s):").arg(device_count);
QMessageBox::information(this, tr("Info"), status);

QString有格式化方法吗?您可以使用
sprintf
std::stringstream
,然后将其传递给
QString
。提醒:您是否已在您所问问题的所有答案上单击绿色复选标记?