QT中的QMessageBox::warning

查看API:

StandardButton QMessageBox::warning ( QWidget * parent, const QString & title, const QString & text,StandardButtons buttons = Ok, StandardButton defaultButton = NoButton ) [static]

可以知道其用途:

1、首先注意warning是小写,不是大写!大写的Warning(QMessageBox::Warning是存在的);

2、后面连个参数有默认值可以不填;

3、第一个参数必须是QWidget的子类或就就是个QWidget,很多人发现网上很多写法是第一个参数为this,于是他就写this,这是不对的,this只有在调用的对象是继承自QWidget时才是对的。

原文地址:https://www.cnblogs.com/immortalBlog/p/14698810.html