QT 对话框二

QMessageBox类
information()函数,主要是提示功能,不需要用户选择
StandardButton QMessageBox::information
(
    QWidget *parent,//消息框父窗口指针
    const QString & title,//消息框标题栏
    const QString & text,消息框文字提示信息
    StandardButtons buttons=Ok,
    StandardButton defaultButton=No
)
void Widget::btn_click()
{
    /*一般不适用后两个参数*/
    QMessageBox::information(this,"提示信息","提示内容");
}
QMessageBox类
warning()函数:
warning消息框使用QMessageBox::warning()函数完成,函数形式如下
StandardButton QMessageBox::warning
(
    QWidget *parent,//消息框父窗口指针
    const QString & title,//消息框标题栏
    const QString & text,消息框文字提示信息
    StandardButtons buttons=Ok,
    StandardButton defaultButton=No
)
void Widget::btn_click()
{
    /*和information()函数类似,只是页面上多了一个警告标志*/
    if(QMessageBox::warning(this,"警告","你修改的内容还未保存,是否要保存队该文件的修改!",QMessageBox::Save|QMessageBox::Discard|QMessageBox::Cancel,QMessageBox::Save)==QMessageBox::Save)
    {
        setWindowTitle("save");
    }
}
QMessageBox类
critical()函数--严重错误:
critical消息框使用QMessageBox::critical()函数完成,函数形式如下
StandardButton QMessageBox::critical
(
    QWidget *parent,//消息框父窗口指针
    const QString & title,//消息框标题栏
    const QString & text,消息框文字提示信息
    StandardButtons buttons=Ok,
    StandardButton defaultButton=No
)
void Widget::btn_click()
{
    QMessageBox::critical(this,"严重错误","该文件不可以删除!");
}
QMessageBox类
about()函数:
about消息框使用QMessageBox::about()函数完成,函数形式如下
void QMessageBox::about
(
    QWidget *parent,//消息框父窗口指针
    const QString & title,//消息框标题栏
    const QString & text,消息框文字提示信息
)
void Widget::btn_click()
{
    QMessageBox::about(this,"关于","这是本公司版权软件,盗版必究!");
}
原文地址:https://www.cnblogs.com/zhanggaofeng/p/5987934.html