QT(03)标准对话框&布局&样式表

标准对话框

  标准消息对话框

    QMessageBox::information   提示消息

    QMessageBox:: critical     错误消息

    QMessageBox::warning     警告消息

    QMessageBox::question    询问选择(是否需要此动作)

    standarbutton: Abort , Retry , Ignore等 消息对话框中的交互按钮 ,  可以通过setButtonText( )修改按钮的显示的text

 enum StandardButton {
        // keep this in sync with QDialogButtonBox::StandardButton and QPlatformDialogHelper::StandardButton
        NoButton           = 0x00000000,
        Ok                 = 0x00000400,
        Save               = 0x00000800,
        SaveAll            = 0x00001000,
        Open               = 0x00002000,
        Yes                = 0x00004000,
        YesToAll           = 0x00008000,
        No                 = 0x00010000,
        NoToAll            = 0x00020000,
        Abort              = 0x00040000,
        Retry              = 0x00080000,
        Ignore             = 0x00100000,
        Close              = 0x00200000,
        Cancel             = 0x00400000,
        Discard            = 0x00800000,
        Help               = 0x01000000,
        Apply              = 0x02000000,
        Reset              = 0x04000000,
        RestoreDefaults    = 0x08000000,

        FirstButton        = Ok,                // internal
        LastButton         = RestoreDefaults,   // internal

        YesAll             = YesToAll,          // obsolete
        NoAll              = NoToAll,           // obsolete

        Default            = 0x00000100,        // obsolete
        Escape             = 0x00000200,        // obsolete
        FlagMask           = 0x00000300,        // obsolete
        ButtonMask         = ~FlagMask          // obsolete
    };
StandarButton

    QMessageBox::StandarButton reply;  定义一个标准按钮对象,该对象可以接收 用户点击的 标准按钮返回的值, 比如

QMessageBox::StandardButton reply;
reply = QMessageBox::critical(this,
QString::fromLocal8Bit("标准警告对话框"),
QString::fromLocal8Bit("这里填写需要警告的内容"),
QMessageBox::Abort |QMessageBox::Retry | MessageBox::Ignore);
//使用reply 接住用户的选择
if (reply == QMessageBox::Abort)
    ui‐>lineEditCritical‐>setText(tr("Abort"));
else if (reply == QMessageBox::Retry)
    ui‐>lineEditCritical‐>setText(tr("Retry"));
else
    ui‐>lineEditCritical‐>setText(tr("Ignore"));
}
View Code

     QMessageBox msgbox;  自定义一个消息对话框 , title text icon  standarbutton 等都是没有的, 需要通过对象继承属性进行添加或修改

  标准文件对话框  QFileDialog

  标准颜色对话框  QColorDialog

  标准字体对话框  QFontDialog

  标准输入对话框  QInputDialog

布局 : 通过ui界面的 Layouts 和 Spacers 进行排版

样式表: 按钮的 悬停 点击 点击后的颜色, 背景色 背景图 ,图标 ,圆角,方角等这样的 都是样式, 

    设置样式表的 qss 语法和css的差不多;  https://blog.csdn.net/goforwardtostep/article/details/53464925

原文地址:https://www.cnblogs.com/yxnrh/p/13360122.html