当前位置: 首页>>代码示例>>C++>>正文


C++ QDialogButtonBox::buttonRole方法代码示例

本文整理汇总了C++中QDialogButtonBox::buttonRole方法的典型用法代码示例。如果您正苦于以下问题:C++ QDialogButtonBox::buttonRole方法的具体用法?C++ QDialogButtonBox::buttonRole怎么用?C++ QDialogButtonBox::buttonRole使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDialogButtonBox的用法示例。


在下文中一共展示了QDialogButtonBox::buttonRole方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: confirm

/*!
    Opens an confirmation message box with the specified \a title, \a text and \a confirmation.
    The standard \a buttons are added to the message box. \a defaultButton specifies 
    the button used when Enter is pressed. \a defaultButton must refer to a button that
    was given in \a buttons. If \a defaultButton is QMessageBox::NoButton, QMessageBox
    chooses a suitable default automatically.

    Returns the identity of the standard button that was clicked.
    If Esc was pressed instead, the escape button is returned.

    If \a parent is \c 0, the message box is an application modal dialog box.
    If \a parent is a widget, the message box is window modal relative to \a parent.
 */
QMessageBox::StandardButton QxtConfirmationMessage::confirm(QWidget* parent,
        const QString& title, const QString& text, const QString& confirmation,
        QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
{
    QxtConfirmationMessage msgBox(QMessageBox::NoIcon, title, text, confirmation, QMessageBox::NoButton, parent);
    QDialogButtonBox* buttonBox = qFindChild<QDialogButtonBox*>(&msgBox);
    Q_ASSERT(buttonBox != 0);

    uint mask = QMessageBox::FirstButton;
    while (mask <= QMessageBox::LastButton)
    {
        uint sb = buttons & mask;
        mask <<= 1;
        if (!sb)
            continue;
        QPushButton* button = msgBox.addButton((QMessageBox::StandardButton)sb);
        // Choose the first accept role as the default
        if (msgBox.defaultButton())
            continue;
        if ((defaultButton == QMessageBox::NoButton && buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole)
                || (defaultButton != QMessageBox::NoButton && sb == uint(defaultButton)))
            msgBox.setDefaultButton(button);
    }
    if (msgBox.exec() == -1)
        return QMessageBox::Cancel;
    return msgBox.standardButton(msgBox.clickedButton());
}
开发者ID:mcu786,项目名称:OpenPilot-1,代码行数:40,代码来源:qxtconfirmationmessage.cpp

示例2: CustomMessageBox

int CustomMessageBox(QWidget *parent,QMessageBox::Icon icon,const QString& title,const QString& text,QMessageBox::StandardButtons buttons,QMessageBox::StandardButton defaultButton,
                     QString ButtonYesText,QString ButtonNoText) {
    Qt::WindowFlags Flags=(Qt::Dialog|Qt::CustomizeWindowHint|Qt::WindowSystemMenuHint|Qt::WindowMaximizeButtonHint)&(~Qt::WindowMinimizeButtonHint);

    QMessageBox         msgBox(icon,title,text,QMessageBox::NoButton,parent,Flags);
    QDialogButtonBox    *buttonBox = msgBox.findChild<QDialogButtonBox*>();

    uint mask = QMessageBox::FirstButton;
    while (mask <= QMessageBox::LastButton) {
        uint sb = buttons & mask;
        mask <<= 1;
        if (!sb) continue;
        QPushButton *button = msgBox.addButton((QMessageBox::StandardButton)sb);
        if ((sb==QMessageBox::Yes)&&(!ButtonYesText.isEmpty())) button->setText(ButtonYesText);
        if ((sb==QMessageBox::No)&&(!ButtonNoText.isEmpty())) button->setText(ButtonNoText);
        // Choose the first accept role as the default
        if (msgBox.defaultButton()) continue;
        if ((defaultButton == QMessageBox::NoButton && buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole)
            || (defaultButton != QMessageBox::NoButton && sb == uint(defaultButton)))
            msgBox.setDefaultButton(button);
    }
    msgBox.setWindowModality(Qt::ApplicationModal);
    if (msgBox.exec() == -1) return QMessageBox::Cancel;
    return msgBox.standardButton(msgBox.clickedButton());
}
开发者ID:JonasCz,项目名称:ffdiaporama-1604-builds,代码行数:25,代码来源:_QCustomDialog.cpp

示例3: keyPressEvent

void TaskView::keyPressEvent(QKeyEvent* ke)
{
    if (ActiveCtrl && ActiveDialog) {
        if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter) {
            // get all buttons of the complete task dialog
            QList<QPushButton*> list = this->findChildren<QPushButton*>();
            for (int i=0; i<list.size(); ++i) {
                QPushButton *pb = list.at(i);
                if (pb->isDefault() && pb->isVisible()) {
                    if (pb->isEnabled())
                        pb->click();
                    return;
                }
            }
        }
        else if (ke->key() == Qt::Key_Escape) {
            // get only the buttons of the button box
            QDialogButtonBox* box = ActiveCtrl->standardButtons();
            QList<QAbstractButton*> list = box->buttons();
            for (int i=0; i<list.size(); ++i) {
                QAbstractButton *pb = list.at(i);
                if (box->buttonRole(pb) == QDialogButtonBox::RejectRole) {
                    if (pb->isEnabled())
                        pb->click();
                    return;
                }
            }
        }
    }
    else {
        QScrollArea::keyPressEvent(ke);
    }
}
开发者ID:Daedalus12,项目名称:FreeCAD_sf_master,代码行数:33,代码来源:TaskView.cpp

示例4: msgBox

static QMessageBox::StandardButton showNewMessageBox(QWidget *parent, QMessageBox::Icon icon,
    const QString &title, const QString &text, QMessageBox::StandardButtons buttons,
    QMessageBox::StandardButton defaultButton)
{
    QMessageBox msgBox(icon, title, text, QMessageBox::NoButton, parent);
    QDialogButtonBox *buttonBox = msgBox.findChild<QDialogButtonBox *>();
    Q_ASSERT(buttonBox != 0);

    uint mask = QMessageBox::FirstButton;
    while (mask <= QMessageBox::LastButton) {
        uint sb = buttons & mask;
        mask <<= 1;
        if (!sb)
            continue;
        QPushButton *button = msgBox.addButton((QMessageBox::StandardButton)sb);
        // Choose the first accept role as the default
        if (msgBox.defaultButton())
            continue;
        if ((defaultButton == QMessageBox::NoButton
            && buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole)
            || (defaultButton != QMessageBox::NoButton && sb == uint(defaultButton))) {
                msgBox.setDefaultButton(button);
        }
    }
#if defined(Q_OS_OSX)
    msgBox.setWindowModality(Qt::WindowModal);
#endif
    if (msgBox.exec() == -1)
        return QMessageBox::Cancel;
    return msgBox.standardButton(msgBox.clickedButton());
}
开发者ID:olear,项目名称:qtifw,代码行数:31,代码来源:messageboxhandler.cpp

示例5: tabChanged

/**
  * @brief the current tab changed
  */
void OpenNIC::tabChanged(int tab)
{
	QDialogButtonBox* buttonBox = ui->buttonBox;
	QList<QAbstractButton *> buttons = buttonBox->buttons();
	for(int n=0; n < buttons.count(); n++)
	{
		QAbstractButton* button = buttons.at(n);
		if (buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole || buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole)
		{
			if ( tab == 1 || tab == 5 )
			{
				button->setEnabled(true);
			}
			else
			{
				button->setEnabled(false);
			}
		}
	}
}
开发者ID:8bitgeek,项目名称:OpenNIC-Wizard,代码行数:23,代码来源:opennic.cpp

示例6: done

/*!
    \reimp
 */
void QxtConfirmationMessage::done(int result)
{
    QDialogButtonBox* buttons = qFindChild<QDialogButtonBox*>(this);
    Q_ASSERT(buttons != 0);

    int role = buttons->buttonRole(clickedButton());
    if (qxt_d().confirm->isChecked() &&
            (qxt_d().remember || role != QDialogButtonBox::RejectRole))
    {
        qxt_d().doNotShowAgain(result);
    }
    QMessageBox::done(result);
}
开发者ID:mcu786,项目名称:OpenPilot-1,代码行数:16,代码来源:qxtconfirmationmessage.cpp

示例7: keyPressEvent

void TaskView::keyPressEvent(QKeyEvent* ke)
{
    if (ActiveCtrl && ActiveDialog) {
        if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter) {
            // get all buttons of the complete task dialog
            QList<QPushButton*> list = this->findChildren<QPushButton*>();
            for (int i=0; i<list.size(); ++i) {
                QPushButton *pb = list.at(i);
                if (pb->isDefault() && pb->isVisible()) {
                    if (pb->isEnabled()) {
#if defined(FC_OS_MACOSX)
                        // #0001354: Crash on using Enter-Key for confirmation of chamfer or fillet entries
                        QPoint pos = QCursor::pos();
                        QCursor::setPos(pb->parentWidget()->mapToGlobal(pb->pos()));
#endif
                        pb->click();
#if defined(FC_OS_MACOSX)
                        QCursor::setPos(pos);
#endif
                    }
                    return;
                }
            }
        }
        else if (ke->key() == Qt::Key_Escape) {
            // get only the buttons of the button box
            QDialogButtonBox* box = ActiveCtrl->standardButtons();
            QList<QAbstractButton*> list = box->buttons();
            for (int i=0; i<list.size(); ++i) {
                QAbstractButton *pb = list.at(i);
                if (box->buttonRole(pb) == QDialogButtonBox::RejectRole) {
                    if (pb->isEnabled()) {
#if defined(FC_OS_MACOSX)
                        // #0001354: Crash on using Enter-Key for confirmation of chamfer or fillet entries
                        QPoint pos = QCursor::pos();
                        QCursor::setPos(pb->parentWidget()->mapToGlobal(pb->pos()));
#endif
                        pb->click();
#if defined(FC_OS_MACOSX)
                        QCursor::setPos(pos);
#endif
                    }
                    return;
                }
            }
        }
    }
    else {
        QScrollArea::keyPressEvent(ke);
    }
}
开发者ID:AllenBootung,项目名称:FreeCAD,代码行数:51,代码来源:TaskView.cpp

示例8: dialogButtonsAction

void LxQtPanelPluginConfigDialog::dialogButtonsAction(QAbstractButton *btn)
{
    QDialogButtonBox *box = qobject_cast<QDialogButtonBox*>(btn->parent());

    if (box && box->buttonRole(btn) == QDialogButtonBox::ResetRole)
    {
        mOldSettings.loadToSettings();
        loadSettings();
    }
    else
    {
        close();
    }
}
开发者ID:hendrikstill,项目名称:lxqt-panel,代码行数:14,代码来源:lxqtpanelpluginconfigdialog.cpp

示例9: buttonClicked

void ChordsManager::buttonClicked(QAbstractButton *button){
    QDialogButtonBox* buttonBox = (QDialogButtonBox*)sender();
    if(buttonBox->buttonRole(button)==QDialogButtonBox::ResetRole){
        qDebug() << "Restore";
    }
}
开发者ID:lbaudouin,项目名称:TabZ,代码行数:6,代码来源:chordsmanager.cpp

示例10: setStandardKeys

void shortcuts::setStandardKeys(QWidget* widget)
{
  if (!widget)
    return;

  // Add standard shortcuts to applicable buttons
  bool hasShortcut = false;
  QPushButton* button;

  // For Save
  button = widget->findChild<QPushButton*>("_save");
  if (button)
  {
    button->setShortcut(QKeySequence::Save);
    button->setToolTip(button->text().remove("&")  + " " +
                       button->shortcut().toString(QKeySequence::NativeText));
    hasShortcut = true;
  }
  if (!hasShortcut) // Because some screens have both
  {
    // For Post
    button = widget->findChild<QPushButton*>("_post");
    if (button)
    {
      button->setShortcut(QKeySequence::Save);
      button->setToolTip(button->text().remove("&")  + " " +
                         button->shortcut().toString(QKeySequence::NativeText));
    }
  }
  if (!hasShortcut)
  {
    QDialogButtonBox* bb = widget->findChild<QDialogButtonBox*>();
    if (bb)
    {
      QList<QAbstractButton*> buttons =  bb->buttons();
      for (int i = 0; i < buttons.size(); ++i)
      {
        QAbstractButton *bbutton = buttons.at(i);
        QDialogButtonBox::ButtonRole btnrole = bb->buttonRole(buttons.at(i));
        if (btnrole == QDialogButtonBox::AcceptRole)
        {
          bbutton->setShortcut(QKeySequence::Save);
          bbutton->setToolTip(bbutton->text().remove("&")  + " " +
                              bbutton->shortcut().toString(QKeySequence::NativeText));

        }
        else if (btnrole == QDialogButtonBox::RejectRole)
        {
          bbutton->setShortcut(QKeySequence::Close);
          bbutton->setToolTip(bbutton->text().remove("&")  + " " +
                              bbutton->shortcut().toString(QKeySequence::NativeText));

        }
      }
    }
  }

  // For Close
  hasShortcut = false;
  button = widget->findChild<QPushButton*>("_close");
  if (button)
  {
    button->setShortcut(QKeySequence::Close);
    button->setToolTip(button->text().remove("&")  + " " +
                       button->shortcut().toString(QKeySequence::NativeText));
    hasShortcut = true;
  }
  if (!hasShortcut) // Because some screens have both
  {
    // For Post
    button = widget->findChild<QPushButton*>("_cancel");
    if (button)
    {
      button->setShortcut(QKeySequence::Close);
      button->setToolTip(button->text().remove("&")  + " " +
                         button->shortcut().toString(QKeySequence::NativeText));
    }
  }

  // For New
  button = widget->findChild<QPushButton*>("_new");
  if (button)
  {
    button->setShortcut(QKeySequence::New);
    button->setToolTip(button->text().remove("&")  + " " +
                       button->shortcut().toString(QKeySequence::NativeText));
    hasShortcut = true;
  }

  // For Print
  button = widget->findChild<QPushButton*>("_print");
  if (button)
  {
    button->setShortcut(QKeySequence::Print);
    button->setToolTip(button->text().remove("&")  + " " +
                       button->shortcut().toString(QKeySequence::NativeText));
    hasShortcut = true;
  }

  // For Query
//.........这里部分代码省略.........
开发者ID:AlFoX,项目名称:qt-client,代码行数:101,代码来源:shortcuts.cpp


注:本文中的QDialogButtonBox::buttonRole方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。