⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qmessagebox.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        button = button0;    } else if (button1 & flags) {        button = button1;    } else if (button2 & flags) {        button = button2;    }    return q->button(newButton(button));}void QMessageBoxPrivate::addOldButtons(int button0, int button1, int button2){    Q_Q(QMessageBox);    q->addButton(newButton(button0));    q->addButton(newButton(button1));    q->addButton(newButton(button2));    q->setDefaultButton(        static_cast<QPushButton *>(findButton(button0, button1, button2, QMessageBox::Default)));    q->setEscapeButton(findButton(button0, button1, button2, QMessageBox::Escape));    compatMode = detectedCompat(button0, button1, button2);}QAbstractButton *QMessageBoxPrivate::abstractButtonForId(int id) const{    Q_Q(const QMessageBox);    QAbstractButton *result = customButtonList.value(id);    if (result)        return result;    if (id & QMessageBox::FlagMask)    // for compatibility with Qt 4.0/4.1 (even if it is silly)        return 0;    return q->button(newButton(id));}int QMessageBoxPrivate::showOldMessageBox(QWidget *parent, QMessageBox::Icon icon,                                          const QString &title, const QString &text,                                          int button0, int button1, int button2){    QMessageBox messageBox(icon, title, text, QMessageBox::NoButton, parent);    messageBox.d_func()->addOldButtons(button0, button1, button2);    return messageBox.exec();}int QMessageBoxPrivate::showOldMessageBox(QWidget *parent, QMessageBox::Icon icon,                                            const QString &title, const QString &text,                                            const QString &button0Text,                                            const QString &button1Text,                                            const QString &button2Text,                                            int defaultButtonNumber,                                            int escapeButtonNumber){    QMessageBox messageBox(icon, title, text, QMessageBox::NoButton, parent);    QString myButton0Text = button0Text;    if (myButton0Text.isEmpty())        myButton0Text = QDialogButtonBox::tr("OK");    messageBox.addButton(myButton0Text, QMessageBox::ActionRole);    if (!button1Text.isEmpty())        messageBox.addButton(button1Text, QMessageBox::ActionRole);    if (!button2Text.isEmpty())        messageBox.addButton(button2Text, QMessageBox::ActionRole);    const QList<QAbstractButton *> &buttonList = messageBox.d_func()->customButtonList;    messageBox.setDefaultButton(static_cast<QPushButton *>(buttonList.value(defaultButtonNumber)));    messageBox.setEscapeButton(buttonList.value(escapeButtonNumber));    return messageBox.exec();}void QMessageBoxPrivate::retranslateStrings(){#ifndef QT_NO_TEXTEDIT    if (detailsButton)        detailsButton->setText(detailsText->isHidden() ? detailsText->label(HideLabel) : detailsText->label(ShowLabel));#endif#if defined(QT_NON_COMMERCIAL)    QT_NC_MSGBOX#else    *translatedTextAboutQt = QMessageBox::tr(        "<h3>About Qt</h3>"        "%1<p>Qt is a C++ toolkit for cross-platform "        "application development.</p>"        "<p>Qt provides single-source "        "portability across MS&nbsp;Windows, Mac&nbsp;OS&nbsp;X, "        "Linux, and all major commercial Unix variants. Qt is also"        " available for embedded devices as Qtopia Core.</p>"        "<p>Qt is a Trolltech product. See "        "<a href=\"http://www.trolltech.com/qt/\">www.trolltech.com/qt/</a> for more information.</p>"       )#if QT_EDITION != QT_EDITION_OPENSOURCE       .arg(QMessageBox::tr("<p>This program uses Qt version %1.</p>"))#else       .arg(QMessageBox::tr("<p>This program uses Qt Open Source Edition version %1.</p>"               "<p>Qt Open Source Edition is intended for the development "               "of Open Source applications. You need a commercial Qt "               "license for development of proprietary (closed source) "               "applications.</p>"               "<p>Please see <a href=\"http://www.trolltech.com/company/model/\">www.trolltech.com/company/model/</a> "               "for an overview of Qt licensing.</p>"))#endif       .arg(QLatin1String(QT_VERSION_STR));#endif}/*!    \obsolete    Constructs a message box with a \a title, a \a text, an \a icon,    and up to three buttons.    The \a icon must be one of the following:    \list    \o QMessageBox::NoIcon    \o QMessageBox::Question    \o QMessageBox::Information    \o QMessageBox::Warning    \o QMessageBox::Critical    \endlist    Each button, \a button0, \a button1 and \a button2, can have one    of the following values:    \list    \o QMessageBox::NoButton    \o QMessageBox::Ok    \o QMessageBox::Cancel    \o QMessageBox::Yes    \o QMessageBox::No    \o QMessageBox::Abort    \o QMessageBox::Retry    \o QMessageBox::Ignore    \o QMessageBox::YesAll    \o QMessageBox::NoAll    \endlist    Use QMessageBox::NoButton for the later parameters to have fewer    than three buttons in your message box. If you don't specify any    buttons at all, QMessageBox will provide an Ok button.    One of the buttons can be OR-ed with the QMessageBox::Default    flag to make it the default button (clicked when Enter is    pressed).    One of the buttons can be OR-ed with the QMessageBox::Escape flag    to make it the cancel or close button (clicked when \key Esc is    pressed).    \quotefromfile snippets/dialogs/dialogs.cpp    \skipto // hardware failure    \skipto QMessageBox mb("Application Name",    \printuntil // try again    If \a parent is 0, the message box becomes an application-global    modal dialog box. If \a parent is a widget, the message box    becomes modal relative to \a parent.    The \a parent and \a f arguments are passed to    the QDialog constructor.    \sa setWindowTitle(), setText(), setIcon()*/QMessageBox::QMessageBox(const QString &title, const QString &text, Icon icon,                             int button0, int button1, int button2, QWidget *parent,                             Qt::WindowFlags f)    : QDialog(*new QMessageBoxPrivate, parent,              f /*| Qt::MSWindowsFixedSizeDialogHint #### */| Qt::WindowTitleHint | Qt::WindowSystemMenuHint){    Q_D(QMessageBox);    d->init(title, text);    setIcon(icon);    d->addOldButtons(button0, button1, button2);}/*!    \obsolete    Opens an information message box with the given \a title and the    \a text. The dialog may have up to three buttons. Each of the    buttons, \a button0, \a button1 and \a button2 may be set to one    of the following values:    \list    \o QMessageBox::NoButton    \o QMessageBox::Ok    \o QMessageBox::Cancel    \o QMessageBox::Yes    \o QMessageBox::No    \o QMessageBox::Abort    \o QMessageBox::Retry    \o QMessageBox::Ignore    \o QMessageBox::YesAll    \o QMessageBox::NoAll    \endlist    If you don't want all three buttons, set the last button, or last    two buttons to QMessageBox::NoButton.    One button can be OR-ed with QMessageBox::Default, and one    button can be OR-ed with QMessageBox::Escape.    Returns the identity (QMessageBox::Ok, or QMessageBox::No, etc.)    of the button that was clicked.    If \a parent is 0, the message box becomes an application-global    modal dialog box. If \a parent is a widget, the message box    becomes modal relative to \a parent.    \sa question(), warning(), critical()*/int QMessageBox::information(QWidget *parent, const QString &title, const QString& text,                               int button0, int button1, int button2){    return QMessageBoxPrivate::showOldMessageBox(parent, Information, title, text,                                                   button0, button1, button2);}/*!    \obsolete    \overload    Displays an information message box with the given \a title and    \a text, as well as one, two or three buttons. Returns the index    of the button that was clicked (0, 1 or 2).    \a button0Text is the text of the first button, and is optional.    If \a button0Text is not supplied, "OK" (translated) will be    used. \a button1Text is the text of the second button, and is    optional. \a button2Text is the text of the third button, and is    optional. \a defaultButtonNumber (0, 1 or 2) is the index of the    default button; pressing Return or Enter is the same as clicking    the default button. It defaults to 0 (the first button). \a    escapeButtonNumber is the index of the escape button; pressing    \key Esc is the same as clicking this button. It defaults to -1;    supply 0, 1 or 2 to make pressing \key Esc equivalent to clicking    the relevant button.    If \a parent is 0, the message box becomes an application-global    modal dialog box. If \a parent is a widget, the message box    becomes modal relative to \a parent.    \sa question(), warning(), critical()*/int QMessageBox::information(QWidget *parent, const QString &title, const QString& text,                               const QString& button0Text, const QString& button1Text,                               const QString& button2Text, int defaultButtonNumber,                               int escapeButtonNumber){    return QMessageBoxPrivate::showOldMessageBox(parent, Information, title, text,                                                   button0Text, button1Text, button2Text,                                                   defaultButtonNumber, escapeButtonNumber);}/*!    \obsolete    Opens a question message box with the given \a title and \a text.    The dialog may have up to three buttons. Each of the buttons, \a    button0, \a button1 and \a button2 may be set to one of the    following values:    \list    \o QMessageBox::NoButton    \o QMessageBox::Ok    \o QMessageBox::Cancel    \o QMessageBox::Yes    \o QMessageBox::No    \o QMessageBox::Abort    \o QMessageBox::Retry    \o QMessageBox::Ignore    \o QMessageBox::YesAll    \o QMessageBox::NoAll    \endlist    If you don't want all three buttons, set the last button, or last    two buttons to QMessageBox::NoButton.    One button can be OR-ed with QMessageBox::Default, and one    button can be OR-ed with QMessageBox::Escape.    Returns the identity (QMessageBox::Yes, or QMessageBox::No, etc.)    of the button that was clicked.    If \a parent is 0, the message box becomes an application-global    modal dialog box. If \a parent is a widget, the message box    becomes modal relative to \a parent.    \sa information(), warning(), critical()*/int QMessageBox::question(QWidget *parent, const QString &title, const QString& text,                            int button0, int button1, int button2){    return QMessageBoxPrivate::showOldMessageBox(parent, Question, title, text,                                                   button0, button1, button2);}/*!    \obsolete    \overload    Displays a question message box with the given \a title and \a    text, as well as one, two or three buttons. Returns the index of    the button that was clicked (0, 1 or 2).    \a button0Text is the text of the first button, and is optional.    If \a button0Text is not supplied, "OK" (translated) will be used.    \a button1Text is the text of the second button, and is optional.    \a button2Text is the text of the third button, and is optional.    \a defaultButtonNumber (0, 1 or 2) is the index of the default    button; pressing Return or Enter is the same as clicking the    default button. It defaults to 0 (the first button). \a    escapeButtonNumber is the index of the Escape button; pressing    Escape is the same as clicking this button. It defaults to -1;    supply 0, 1 or 2 to make pressing Escape equivalent to clicking    the relevant button.    If \a parent is 0, the message box becomes an application-global    modal dialog box. If \a parent is a widget, the message box    becomes modal relative to \a parent.    \sa information(), warning(), critical()*/int QMessageBox::question(QWidget *parent, const QString &title, const QString& text,                            const QString& button0Text, const QString& button1Text,                            const QString& button2Text, int defaultButtonNumber,                            int escapeButtonNumber){    return QMessageBoxPrivate::showOldMessageBox(parent, Question, title, text,                                                   button0Text, button1Text, button2Text,                                                   defaultButtonNumber, escapeButtonNumber);}/*!    \obsolete    Opens a warning message box with the given \a title and \a text.    The dialog may have up to three buttons. Each of the button    parameters, \a button0, \a button1 and \a button2 may be set to    one of the following values:    \list    \o QMessageBox::NoButton    \o QMessageBox::Ok    \o QMessageBox::Cancel    \o QMessageBox::Yes    \o QMessageBox::No    \o QMessageBox::Abort    \o QMessageBox::Retry    \o QMessageBox::Ignore    \o QMessageBox::YesAll    \o QMessageBox::NoAll    \endlist    If you don't want all three buttons, set the last button, or last    two buttons to QMessageBox::NoButton.    One button can be OR-ed with QMessageBox::Default, and one    button can be OR-ed with QMessageBox::Escape.    Returns the identity (QMessageBox::Ok or QMessageBox::No or ...)    of the button that was clicked.    If \a parent is 0, the message box becomes an application-global    modal dialog box. If \a parent is a widget, the message box    becomes modal relative to \a parent.    \sa information(), question(), critical()*/int QMessageBox::warning(QWidget *parent, const QString &title, const QString& text,                           int button0, int button1, int button2){    return QMessageBoxPrivate::showOldMessageBox(parent, Warning, title, text,                                                   button0, button1, button2);}/*!    \obsolete    \overload    Displays a warning message box with the given \a title and \a    text, as well as one, two, or three buttons. Returns the number    of the button that was clicked (0, 1, or 2).    \a button0Text is the text of the first button, and is optional.    If \a button0Text is not supplied, "OK" (translated) will be used.    \a button1Text is the text of the second button, and is optional,    and \a button2Text is the text of the third button, and is    optional. \a defaultButtonNumber (0, 1 or 2) is the index of the    default button; pressing Return or Enter is the same as clicking    the default button. It defaults to 0 (the first button). \a

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -