本文整理汇总了C++中QDialogButtonBox类的典型用法代码示例。如果您正苦于以下问题:C++ QDialogButtonBox类的具体用法?C++ QDialogButtonBox怎么用?C++ QDialogButtonBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QDialogButtonBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QDialog
SelectExpiryDate::SelectExpiryDate(QWidget* parent, QDateTime date)
: QDialog(parent)
{
setWindowTitle(i18n("Choose New Expiration"));
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
QWidget *mainWidget = new QWidget(this);
QVBoxLayout *mainLayout = new QVBoxLayout(this);
setLayout(mainLayout);
mainLayout->addWidget(mainWidget);
okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
connect(buttonBox, &QDialogButtonBox::accepted, this, &SelectExpiryDate::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &SelectExpiryDate::reject);
okButton->setDefault(true);
QWidget *page = new QWidget(this);
m_unlimited = new QCheckBox(i18nc("Key has unlimited lifetime", "Unlimited"), page);
m_unlimited->setChecked(date.isNull());
if (date.isNull())
date = QDateTime::currentDateTime();
m_datepicker = new KDatePicker(date.date(), page);
if (date.isNull()) {
m_datepicker->setEnabled(false);
m_unlimited->setChecked(true);
}
QVBoxLayout *layout = new QVBoxLayout(page);
layout->setSpacing(3);
layout->addWidget(m_datepicker);
layout->addWidget(m_unlimited);
connect(m_unlimited, &QCheckBox::toggled, this, &SelectExpiryDate::slotEnableDate);
connect(m_datepicker, &KDatePicker::dateChanged, this, &SelectExpiryDate::slotCheckDate);
connect(m_datepicker, &KDatePicker::dateEntered, this, &SelectExpiryDate::slotCheckDate);
mainLayout->addWidget(page);
mainLayout->addWidget(buttonBox);
show();
slotEnableDate(m_unlimited->isChecked());
}
示例2: QDialog
EditPageSetDialog::EditPageSetDialog(QWidget * parent) : QDialog(parent) {
QLOG_DEBUG() << Q_FUNC_INFO;
QStringList cols;
cols << tr("Id") << tr("Title") << tr("Tab count") << tr("Created") << tr("Delete") << tr("Select tabs") << tr("Tabs to delete");
m_setlist = new ColumnarTableWidget(cols);
m_setlist->setKey(ColumnarTableWidget::STATE,SID_PAGESET_EDIT_TAB_LIST_STATE);
readSettings();
setWindowTitle(tr("Edit Tab Set"));
QVBoxLayout * layout = new QVBoxLayout;
layout->addWidget(m_setlist);
int rows = this->loadTitles();
QDialogButtonBox * buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel);
m_loadButton = new QPushButton(tr("Apply"));
buttonBox->addButton(m_loadButton,QDialogButtonBox::ActionRole);
m_loadButton->setVisible(rows > 0);
m_loadButton->setEnabled(false);
connect(m_loadButton,SIGNAL(clicked()),this,SLOT(onApply()));
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
layout->addWidget(buttonBox);
setLayout(layout);
connect(m_setlist,SIGNAL(itemDoubleClicked(QTableWidgetItem *)),this,SLOT(onItemDoubleClicked(QTableWidgetItem *)));
m_dirty = false;
SETTINGS
settings.beginGroup("PageSets");
m_setlist->readConfiguration(settings);
}
示例3: QVERIFY
void TestGui::testAddEntry()
{
EntryView* entryView = m_dbWidget->findChild<EntryView*>("entryView");
QAction* entryNewAction = m_mainWindow->findChild<QAction*>("actionEntryNew");
QVERIFY(entryNewAction->isEnabled());
QToolBar* toolBar = m_mainWindow->findChild<QToolBar*>("toolBar");
QWidget* entryNewWidget = toolBar->widgetForAction(entryNewAction);
QVERIFY(entryNewWidget->isVisible());
QVERIFY(entryNewWidget->isEnabled());
QTest::mouseClick(entryNewWidget, Qt::LeftButton);
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::EditMode);
EditEntryWidget* editEntryWidget = m_dbWidget->findChild<EditEntryWidget*>("editEntryWidget");
QLineEdit* titleEdit = editEntryWidget->findChild<QLineEdit*>("titleEdit");
QTest::keyClicks(titleEdit, "test");
QDialogButtonBox* editEntryWidgetButtonBox = editEntryWidget->findChild<QDialogButtonBox*>("buttonBox");
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::ViewMode);
QModelIndex item = entryView->model()->index(1, 1);
Entry* entry = entryView->entryFromIndex(item);
QCOMPARE(entry->title(), QString("test"));
QCOMPARE(entry->historyItems().size(), 0);
// wait for modified timer
QTRY_COMPARE(m_tabWidget->tabText(m_tabWidget->currentIndex()), QString("NewDatabase.kdbx*"));
QAction* entryEditAction = m_mainWindow->findChild<QAction*>("actionEntryEdit");
QVERIFY(entryEditAction->isEnabled());
QWidget* entryEditWidget = toolBar->widgetForAction(entryEditAction);
QVERIFY(entryEditWidget->isVisible());
QVERIFY(entryEditWidget->isEnabled());
QTest::mouseClick(entryEditWidget, Qt::LeftButton);
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::EditMode);
QTest::keyClicks(titleEdit, "something");
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
QCOMPARE(entry->title(), QString("testsomething"));
QCOMPARE(entry->historyItems().size(), 1);
}
示例4: QDialog
ChooseFileDlg::ChooseFileDlg(QWidget *parent)
: QDialog(parent)
{
new QVBoxLayout(this);
QPushButton *upload = new QPushButton(tr("Choose file to upload..."), this);
connect(upload, SIGNAL(clicked(bool)), this, SLOT(onFileSelect(bool)));
layout()->addWidget(upload);
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
buttons->setCenterButtons(true);
connect(buttons, &QDialogButtonBox::accepted, this, [this]() {
done(QDialog::Accepted);
});
connect(buttons, &QDialogButtonBox::rejected, this, [this]() {
done(QDialog::Rejected);
});
layout()->addWidget(buttons);
}
示例5: QDialog
DeleteThemeDialog::DeleteThemeDialog(QWidget * parent) : QDialog(parent) {
QVBoxLayout * layout = new QVBoxLayout;
setWindowTitle(tr("Delete Theme"));
m_themes = new QComboBox;
QStringList themes = getLexicon()->getThemes();
themes.sort();
m_themes->addItems(themes);
m_currentTheme = getLexicon()->currentTheme();
m_themes->setCurrentText(m_currentTheme);
m_switch = new QComboBox;
m_switch->addItems(themes);
m_currentTheme = getLexicon()->currentTheme();
connect(m_themes,SIGNAL(currentIndexChanged(int)),this,SLOT(onChangeTheme(int)));
m_themes->setCurrentText(m_currentTheme);
m_themes->removeItem(m_themes->findText(m_currentTheme));
// m_switch->removeItem(m_themes->findText(m_currentTheme));
QFormLayout * form = new QFormLayout;
form->addRow(tr("Delete theme"),m_themes);
form->addRow(tr("New theme"),m_switch);
m_deleteButton = new QPushButton(tr("Delete"));
QDialogButtonBox * btns = new QDialogButtonBox(QDialogButtonBox::Cancel);
btns->addButton(m_deleteButton,QDialogButtonBox::AcceptRole);
connect(btns,SIGNAL(accepted()),this,SLOT(accept()));
connect(btns,SIGNAL(rejected()),this,SLOT(reject()));
layout->addWidget(new QLabel(QString(tr("The current theme is \"%1\" and cannot be deleted.")).arg(m_currentTheme)));
layout->addLayout(form);
layout->addWidget(btns);
// layout->addStretch();
setLayout(layout);
if (themes.size() == 1) {
m_deleteButton->setEnabled(false);
}
};
示例6: QDialog
DialogResourceText::DialogResourceText(QString text, QWidget *parent): QDialog(parent)
{
setWindowTitle(tr("Resource Dialog"));
QDialogButtonBox *dialogbuttonbox = new QDialogButtonBox(this);
dialogbuttonbox->setOrientation(Qt::Horizontal);
dialogbuttonbox->setStandardButtons(QDialogButtonBox::Ok);
QTextEdit *textedit = new QTextEdit(this);
textedit->setAcceptRichText(true);
textedit->setText(text);
textedit->setReadOnly(true);
QGridLayout *layout = new QGridLayout(this);
layout->addWidget(textedit);
layout->addWidget(dialogbuttonbox);
connect(dialogbuttonbox, SIGNAL(accepted()), this, SLOT(accept()));
}
示例7: QDialog
OpenGLDebugMessageWindow::OpenGLDebugMessageWindow(QWidget *parent) :
QDialog(parent)
{
m_view = new QTreeView;
m_view->setRootIsDecorated(false);
QDialogButtonBox *buttonBox = new QDialogButtonBox;
QPushButton *closeButton = buttonBox->addButton(QDialogButtonBox::Close);
connect(closeButton, &QPushButton::clicked, this, &QWidget::close);
m_clearButton = buttonBox->addButton(QDialogButtonBox::Reset);
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(m_view);
layout->addWidget(buttonBox);
setLayout(layout);
resize(600, 300);
}
示例8: ParamSetupDialog
SlideFrictionControlSetupDialog::SlideFrictionControlSetupDialog()
: ParamSetupDialog()
{
setWindowTitle("Slide Friction Control Setup");
QVBoxLayout* vbox = new QVBoxLayout();
layout_ = (ParamSetupLayout*) new SlideFrictionControlSetupLayout();
vbox->addLayout(layout_);
QPushButton* okButton = new QPushButton("&Ok");
okButton->setDefault(true);
QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
buttonBox->addButton(okButton, QDialogButtonBox::AcceptRole);
connect(buttonBox,SIGNAL(accepted()), this, SLOT(accept()));
vbox->addWidget(buttonBox);
setLayout(vbox);
}
示例9: QDialog
SendLaterConfigureDialog::SendLaterConfigureDialog(QWidget *parent)
: QDialog(parent)
{
setWindowTitle(i18n("Configure"));
setWindowIcon(QIcon::fromTheme(QStringLiteral("kmail")));
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help);
QVBoxLayout *mainLayout = new QVBoxLayout(this);
setLayout(mainLayout);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
connect(buttonBox, &QDialogButtonBox::rejected, this, &SendLaterConfigureDialog::reject);
mWidget = new SendLaterWidget(this);
mWidget->setObjectName(QStringLiteral("sendlaterwidget"));
connect(mWidget, &SendLaterWidget::sendNow, this, &SendLaterConfigureDialog::sendNow);
mainLayout->addWidget(mWidget);
mainLayout->addWidget(buttonBox);
connect(okButton, &QPushButton::clicked, this, &SendLaterConfigureDialog::slotSave);
readConfig();
KAboutData aboutData = KAboutData(
QStringLiteral("sendlateragent"),
i18n("Send Later Agent"),
QStringLiteral(KDEPIM_VERSION),
i18n("Send emails later agent."),
KAboutLicense::GPL_V2,
i18n("Copyright (C) 2013-2016 Laurent Montel"));
aboutData.addAuthor(i18n("Laurent Montel"),
i18n("Maintainer"), QStringLiteral("[email protected]"));
QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("kmail")));
aboutData.setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"),
i18nc("EMAIL OF TRANSLATORS", "Your emails"));
KHelpMenu *helpMenu = new KHelpMenu(this, aboutData, true);
//Initialize menu
QMenu *menu = helpMenu->menu();
helpMenu->action(KHelpMenu::menuAboutApp)->setIcon(QIcon::fromTheme(QStringLiteral("kmail")));
buttonBox->button(QDialogButtonBox::Help)->setMenu(menu);
}
示例10: QDialog
DialogDeleteEntry::DialogDeleteEntry(QWidget* parent)
: QDialog(parent)
{
setWindowIcon(QIcon(":/images/remove_entry.png"));
setWindowTitle("Remove entry");
QVBoxLayout* mainLayout = new QVBoxLayout();
modelEntry = new QSqlQueryModel();
modelEntry->setQuery("SELECT group_name, real_name, id_entry, category.name, active_entries.entry_id FROM mod_entry_summary, category, active_entries WHERE category.category_id = mod_entry_summary.category_id AND id_entry = active_entries.entry_id");
//summaryModelUnassigned->setHeaderData(0, Qt::Horizontal, tr("Order"));
modelEntry->setHeaderData(0, Qt::Horizontal, tr("Group"));
modelEntry->setHeaderData(1, Qt::Horizontal, tr("Real name 1"));
modelEntry->setHeaderData(3, Qt::Horizontal, tr("Category"));
viewEntry = new QTableView();
//connect(summaryViewUnassigned,SIGNAL(clicked(const QModelIndex&)),this,SLOT(entrySelected(const QModelIndex&)));
viewEntry->setModel(modelEntry);
//summaryViewUnassigned->setColumnHidden(0,true);
viewEntry->setColumnHidden(2,true);
//summaryViewUnassigned->setColumnHidden(4,true);
viewEntry->show();
//summaryViewUnassigned->setMaximumWidth(400);
mainLayout->addWidget(viewEntry);
permaDelete = new QCheckBox("Delete permanently?");
mainLayout->addWidget(permaDelete);
QPushButton* delButton = new QPushButton(QIcon(":/images/graveyard2.png"),"Delete entry");
delButton->setIconSize(QSize(48,48));
delButton->setToolTip("Delete the entry.");
connect(delButton,SIGNAL(clicked()),this,SLOT(deleteEntry()));
QHBoxLayout* btnLayout = new QHBoxLayout();
btnLayout->addWidget(delButton);
btnLayout->addStretch();
mainLayout->addLayout(btnLayout);
QDialogButtonBox* buttonBox = new QDialogButtonBox();
buttonBox->addButton(QDialogButtonBox::Close);
connect(buttonBox,SIGNAL(accepted()),this,SLOT(accept()));
connect(buttonBox,SIGNAL(rejected()),this,SLOT(reject()));
mainLayout->addWidget(buttonBox);
setLayout(mainLayout);
loadSettings();
}
示例11: main
int main(int argc, char ** argv) {
QApplication app{argc, argv};
QWidget w;
QVBoxLayout layout{&w};
// Individual Buttons
QPushButton p1{"button1"}, p2{"button2"};
for (auto p : {&p1, &p2}) {
layout.addWidget(p);
p->setFocusPolicy(Qt::StrongFocus);
}
// A button box
QDialogButtonBox box;
for (auto text : {"button3", "button4"})
box.addButton(text, QDialogButtonBox::NoRole)->setFocusPolicy(Qt::StrongFocus);
layout.addWidget(&box);
w.show();
return app.exec();
}
示例12: QDialog
KNotesKeyDialog::KNotesKeyDialog(KActionCollection *globals, QWidget *parent)
: QDialog(parent)
{
setWindowTitle(i18n("Configure Shortcuts"));
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults);
QVBoxLayout *mainLayout = new QVBoxLayout;
setLayout(mainLayout);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
connect(buttonBox, &QDialogButtonBox::accepted, this, &KNotesKeyDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &KNotesKeyDialog::reject);
m_keyChooser = new KShortcutsEditor(globals, this);
mainLayout->addWidget(m_keyChooser);
mainLayout->addWidget(buttonBox);
connect(buttonBox->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, m_keyChooser, &KShortcutsEditor::allDefault);
readConfig();
}
示例13: QPushButton
QDialogButtonBox *Dialog::createButtons()
{
QPushButton *closeButton = new QPushButton(tr("&Close"));
QPushButton *revertButton = new QPushButton(tr("&Revert"));
QPushButton *submitButton = new QPushButton(tr("&Submit"));
closeButton->setDefault(true);
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
connect(revertButton, SIGNAL(clicked()), this, SLOT(revert()));
connect(submitButton, SIGNAL(clicked()), this, SLOT(submit()));
QDialogButtonBox *buttonBox = new QDialogButtonBox;
buttonBox->addButton(submitButton, QDialogButtonBox::ResetRole);
buttonBox->addButton(revertButton, QDialogButtonBox::ResetRole);
buttonBox->addButton(closeButton, QDialogButtonBox::RejectRole);
return buttonBox;
}
示例14: QFETCH
void tst_AddBookmarkDialog::addbookmarkdialog()
{
QFETCH(QString, url);
QFETCH(QString, title);
QFETCH(QDialogButtonBox::StandardButton, button);
QFETCH(int, menuCount);
QFETCH(int, toolbarCount);
QFETCH(int, select);
BookmarksManager *manager = BrowserApplication::bookmarksManager();
qRegisterMetaType<BookmarkNode *>("BookmarkNode *");
QSignalSpy spy(manager, SIGNAL(entryAdded(BookmarkNode *)));
BookmarkNode *menu = manager->menu();
BookmarkNode *toolbar = manager->toolbar();
QCOMPARE(menu->children().count(), 0);
QCOMPARE(toolbar->children().count(), 0);
SubAddBookmarkDialog dialog(0, manager);
dialog.setUrl(url);
dialog.setTitle(title);
QComboBox *combobox = dialog.findChild<QComboBox*>();
QVERIFY(combobox);
if (select != -1) {
combobox->setCurrentIndex(select);
combobox->view()->setCurrentIndex(combobox->model()->index(select, 0));
}
QDialogButtonBox *buttonBox = dialog.findChild<QDialogButtonBox*>();
QVERIFY(buttonBox);
QPushButton *pushButton = buttonBox->button(button);
pushButton->click();
QCOMPARE(spy.count(), menuCount + toolbarCount);
QCOMPARE(menu->children().count(), menuCount);
QCOMPARE(toolbar->children().count(), toolbarCount);
BookmarkNode *node = 0;
if (menuCount == 1) node = menu->children()[0];
if (toolbarCount == 1) node = toolbar->children()[0];
if (node) {
QCOMPARE(node->title, title);
QCOMPARE(node->url, url);
}
}
示例15: QSpacerItem
void SettingsDialog::createGui()
{
// Header label with large font and a bit of spacing (align with group boxes)
QFont headerLabelFont = m_headerLabel->font();
headerLabelFont.setBold(true);
// Paranoia: Should a font be set in pixels...
const int pointSize = headerLabelFont.pointSize();
if (pointSize > 0)
headerLabelFont.setPointSize(pointSize + 2);
m_headerLabel->setFont(headerLabelFont);
QHBoxLayout *headerHLayout = new QHBoxLayout;
const int leftMargin = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
headerHLayout->addSpacerItem(new QSpacerItem(leftMargin, 0, QSizePolicy::Fixed, QSizePolicy::Ignored));
headerHLayout->addWidget(m_headerLabel);
m_stackedLayout->setMargin(0);
m_stackedLayout->addWidget(new QWidget(this)); // no category selected, for example when filtering
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok |
QDialogButtonBox::Apply |
QDialogButtonBox::Cancel);
connect(buttonBox->button(QDialogButtonBox::Apply), &QAbstractButton::clicked,
this, &SettingsDialog::apply);
connect(buttonBox, &QDialogButtonBox::accepted, this, &SettingsDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &SettingsDialog::reject);
QGridLayout *mainGridLayout = new QGridLayout;
mainGridLayout->addWidget(m_filterLineEdit, 0, 0, 1, 1);
mainGridLayout->addLayout(headerHLayout, 0, 1, 1, 1);
mainGridLayout->addWidget(m_categoryList, 1, 0, 1, 1);
mainGridLayout->addLayout(m_stackedLayout, 1, 1, 1, 1);
mainGridLayout->addWidget(buttonBox, 2, 0, 1, 2);
mainGridLayout->setColumnStretch(1, 4);
setLayout(mainGridLayout);
buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
setMinimumSize(1000, 550);
if (Utils::HostOsInfo::isMacHost())
setMinimumHeight(minimumHeight() * 1.1);
}