QMessageBox::information(nullptr, QString::fromStdString("警告"), QString::fromStdString("筛选表内无内容"));这句有什么错
时间: 2024-04-27 10:20:31 浏览: 17
这句话没有语法错误,可以正常编译和运行。QMessageBox::information 函数接受三个参数,第一个参数是弹出对话框的父窗口,第二个参数是对话框标题,第三个参数是对话框中显示的文本信息。
如果你的程序运行时没有弹出对话框,可能是因为程序没有执行到这句话,或者其他原因导致对话框被隐藏了。你可以检查一下程序代码,确保这句话被执行了,并且尝试将程序窗口最小化或将对话框拖到屏幕中央,看看是否能够找到对话框。
如果问题仍然存在,请提供更多的代码细节和错误信息,以便我更好地帮助你。
相关问题
QMessageBox::warning(nullptr, QString::fromStdString("警告"), QString::fromStdString("筛选表内无内容"),QMessageBox::Yes);这句话有什么错
你的代码中,QMessageBox::warning 函数的第四个参数是 QMessageBox::Yes,这个参数是用来指定对话框的按钮类型(即显示 "Yes" 和 "No" 按钮还是只显示 "Ok" 按钮)。但是,QMessageBox::warning 函数只接受三个参数,因此会编译错误。
如果你想显示 "Yes" 和 "No" 按钮,可以使用 QMessageBox::question 函数,它接受四个参数,第四个参数用于指定按钮类型。修改后的代码如下所示:
```
QMessageBox::StandardButton reply = QMessageBox::question(nullptr, "警告", "筛选表内无内容", QMessageBox::Yes|QMessageBox::No);
if (reply == QMessageBox::Yes) {
// 用户点击了 Yes 按钮
} else {
// 用户点击了 No 按钮
}
```
如果你只想显示 "Ok" 按钮,可以使用 QMessageBox::information 函数,它也接受三个参数,没有按钮类型参数。修改后的代码如下所示:
```
QMessageBox::information(nullptr, "警告", "筛选表内无内容");
```
QMessageBox::information 有那些图标
QMessageBox::information函数可以显示不同类型的图标,包括以下几种:
1. 没有图标(QMessageBox::NoIcon)
2. 信息图标(QMessageBox::Information)
3. 警告消息图标(QMessageBox::Warning)
4. 严重消息图标(QMessageBox::Critical)
以下是一个使用QMessageBox::information函数显示不同图标的示例:
```cpp
#include <QMessageBox>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
// 显示没有图标的消息框
QMessageBox::information(nullptr, "No Icon", "This is a message box with no icon.", QMessageBox::NoIcon);
// 显示信息图标的消息框
QMessageBox::information(nullptr, "Information", "This is a message box with information icon.", QMessageBox::Information);
// 显示警告消息图标的消息框
QMessageBox::information(nullptr, "Warning", "This is a message box with warning icon.", QMessageBox::Warning);
// 显示严重消息图标的消息框
QMessageBox::information(nullptr, "Critical", "This is a message box with critical icon.", QMessageBox::Critical);
return app.exec();
}
```
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)