本文整理汇总了C++中QPushButton::setAutoDefault方法的典型用法代码示例。如果您正苦于以下问题:C++ QPushButton::setAutoDefault方法的具体用法?C++ QPushButton::setAutoDefault怎么用?C++ QPushButton::setAutoDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPushButton
的用法示例。
在下文中一共展示了QPushButton::setAutoDefault方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _passwordDialog
QString GUI::_passwordDialog(const QString& cancel, const QString& body)
{
// we use a hack. It is considered that closing the dialog without explicitly clicking
// disable history is confusing. But we can't distinguish between clicking the cancel
// button and closing the dialog. So instead, we reverse the Ok and Cancel roles,
// so that nothing but explicitly clicking disable history closes the dialog
QString ret;
QInputDialog dialog;
dialog.setWindowTitle(tr("Enter your password"));
dialog.setOkButtonText(cancel);
dialog.setCancelButtonText(tr("Decrypt"));
dialog.setInputMode(QInputDialog::TextInput);
dialog.setTextEchoMode(QLineEdit::Password);
dialog.setLabelText(body);
// problem with previous hack: the default button is disable history, not decrypt.
// use another hack to reverse the default buttons.
// http://www.qtcentre.org/threads/49924-Change-property-of-QInputDialog-button
QList<QDialogButtonBox*> l = dialog.findChildren<QDialogButtonBox*>();
if (!l.isEmpty())
{
QPushButton* ok = l.first()->button(QDialogButtonBox::Ok);
QPushButton* cancel = l.first()->button(QDialogButtonBox::Cancel);
if (ok && cancel)
{
ok->setAutoDefault(false);
ok->setDefault(false);
ok->setText(QApplication::tr("Ok"));
cancel->setAutoDefault(true);
cancel->setDefault(true);
cancel->setText(QApplication::tr("Cancel"));
}
else
{
qWarning() << "PasswordDialog: Missing button!";
}
}
else
{
qWarning() << "PasswordDialog: No QDialogButtonBox!";
}
// using similar code, set QLabels to wrap
for (auto* label : dialog.findChildren<QLabel*>())
label->setWordWrap(true);
while (true)
{
int val = dialog.exec();
if (val == QDialog::Accepted)
return QString();
ret = dialog.textValue();
if (!ret.isEmpty())
return ret;
dialog.setTextValue("");
dialog.setLabelText(body + "\n\n" + tr("You must enter a non-empty password:"));
}
}
示例2: QDialog
DesktopUpdateAvailableDialog::DesktopUpdateAvailableDialog(
const DesktopUpdateInfo& updateInfo,
QWidget *parent) :
QDialog(parent),
updateInfo_(updateInfo),
ui(new Ui::DesktopUpdateAvailableDialog())
{
ui->setupUi(this);
ui->lblIcon->setFixedSize(QSize(64, 64));
ui->label->setText(updateInfo.updateMessage);
ui->buttonBox->clear();
QPushButton* pDownload = new QPushButton(QString::fromUtf8("Download..."));
ui->buttonBox->addButton(pDownload, QDialogButtonBox::AcceptRole);
pDownload->setAutoDefault(false);
pDownload->setDefault(true);
QPushButton* pRemindLater = new QPushButton(QString::fromUtf8("Remind Later"));
ui->buttonBox->addButton(pRemindLater, QDialogButtonBox::RejectRole);
pRemindLater->setAutoDefault(false);
QPushButton* pIgnoreUpdate = new QPushButton(QString::fromUtf8("Ignore Update"));
ui->buttonBox->addButton(pIgnoreUpdate, QDialogButtonBox::DestructiveRole);
pIgnoreUpdate->setAutoDefault(false);
pIgnoreUpdate->setEnabled(!updateInfo.isUrgent);
connect(pIgnoreUpdate, SIGNAL(clicked()),
this, SLOT(permanentlyIgnoreUpdate()));
pRemindLater->setFocus();
}
示例3: initDialog
void SurfaceSettingsDialog::initDialog(){
QLineEdit* uEdit = ui->uDivisionCountLineEdit;
QLineEdit* vEdit = ui->vDivisionCountLineEdit;
QIntValidator* intValidator = new QIntValidator(0, 1000, NULL);
uEdit->setValidator(intValidator);
vEdit->setValidator(intValidator);
std::string uStr;
std::string vStr;
uStr = std::to_string(Surface::uDivisionCount);
vStr = std::to_string(Surface::vDivisionCount);
QString uQStr = QString::fromStdString(uStr);
QString vQStr = QString::fromStdString(vStr);
uEdit->setText(uQStr);
vEdit->setText(vQStr);
QPushButton* cancelButton = ui->cancelButton;
QPushButton* okButton = ui->okButton;
okButton->setDefault(true);
okButton->setAutoDefault(false);
cancelButton->setDefault(false);
cancelButton->setAutoDefault(false);
}
示例4: QDialog
QtGradientDialog::QtGradientDialog(QWidget *parent)
: QDialog(parent), d_ptr(new QtGradientDialogPrivate())
{
// setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
d_ptr->q_ptr = this;
d_ptr->m_ui.setupUi(this);
QPushButton *button = d_ptr->m_ui.buttonBox->button(QDialogButtonBox::Ok);
if (button)
button->setAutoDefault(false);
button = d_ptr->m_ui.buttonBox->button(QDialogButtonBox::Cancel);
if (button)
button->setAutoDefault(false);
connect(d_ptr->m_ui.gradientEditor, SIGNAL(aboutToShowDetails(bool,int)),
this, SLOT(slotAboutToShowDetails(bool,int)));
}
示例5: QDialog
mkdir_dialog::mkdir_dialog(std::string const & path, QWidget * parent)
: QDialog(parent)
{
QVBoxLayout * layout = new QVBoxLayout(this);
QLabel * label = new QLabel;
label->setText(QString("Create new folder in:\n%1").arg(path.c_str()));
layout->addWidget(label);
_dirname = new QLineEdit;
_dirname->setClearButtonEnabled(true);
_dirname->setText("New Folder");
_dirname->selectAll();
layout->addWidget(_dirname);
QHBoxLayout * button_layout = new QHBoxLayout;
QPushButton * ok = new QPushButton("&Ok");
ok->setAutoDefault(true);
connect(ok, SIGNAL(clicked()), this, SLOT(accept()));
button_layout->addWidget(ok);
QPushButton * cancel = new QPushButton("&Cancel");
connect(cancel, SIGNAL(clicked()), this, SLOT(reject()));
button_layout->addWidget(cancel);
layout->addLayout(button_layout);
setWindowTitle("New Folder");
}
示例6: ui
ShareDialog::ShareDialog( const Track& track, QWidget* parent )
: unicorn::Dialog( parent, Qt::Tool ),
ui( new Ui::ShareDialog ),
m_track( track )
{
ui->setupUi( this );
ui->recipients->setType( ItemSelectorWidget::User );
ui->icon->setScaledContents( true );
ui->icon->setHref( m_track.www() );
enableDisableOk();
connect( ui->message, SIGNAL(textChanged()), SLOT(updateCharacterLimit()));
connect( ui->message, SIGNAL(textChanged()), SLOT(enableDisableOk()));
connect( ui->recipients, SIGNAL(changed()), SLOT(enableDisableOk()));
ui->title->setText( unicorn::Label::anchor( m_track.www().toString(), m_track.title() ) );
if ( m_track.album().isNull() )
ui->description->setText( tr( "A track by %1" ).arg( unicorn::Label::anchor( m_track.artist().www().toString(), m_track.artist().name() ) ) );
else
ui->description->setText( tr( "A track by %1 from the release %2" ).arg( unicorn::Label::anchor( m_track.artist().www().toString(), m_track.artist().name() ), unicorn::Label::anchor( m_track.album().www().toString(), m_track.album() ) ) );
m_imageFetcher = new TrackImageFetcher( m_track, Track::MediumImage );
connect( m_imageFetcher, SIGNAL(finished(QPixmap)), ui->icon, SLOT(setPixmap(QPixmap)) );
m_imageFetcher->startAlbum();
QPushButton* dummyDefault = ui->buttons->addButton( QDialogButtonBox::Help );
dummyDefault->setDefault( true );
dummyDefault->setAutoDefault( true );
dummyDefault->setVisible( false );
}
示例7: initUi
void QwwTipWidgetPrivate::initUi() {
Q_Q(QwwTipWidget);
QHBoxLayout *l = new QHBoxLayout;
m_check = new QCheckBox;
m_check->setChecked(true);
l->addWidget(m_check);
l->addStretch();
m_prev = new QPushButton;
m_prev->setIcon(QPixmap(":/wwwidgets/arrowleft.png"));
l->addWidget(m_prev);
m_next = new QPushButton;
m_next->setIcon(QPixmap(":/wwwidgets/arrowright.png"));
l->addWidget(m_next);
m_close = new QPushButton;
m_close->setDefault(true);
m_close->setAutoDefault(true);
l->addWidget(m_close);
QVBoxLayout *vl = new QVBoxLayout(q);
m_browser = new QTextBrowser;
m_browser->setOpenExternalLinks(true);
vl->addWidget(m_browser);
vl->addLayout(l);
q->connect(m_close, SIGNAL(clicked()), q, SIGNAL(closed()));
q->connect(m_prev, SIGNAL(clicked()), q, SLOT(prevTip()));
q->connect(m_next, SIGNAL(clicked()), q, SLOT(nextTip()));
q->setTabOrder(m_close, m_next);
q->setTabOrder(m_next, m_prev);
q->setTabOrder(m_prev, m_check);
q->setTabOrder(m_check, m_close);
q->setFocusProxy(m_close);
retranslateUi();
}
示例8: QDialog
ShutdownDialog::ShutdownDialog(QWidget *parent)
: QDialog(parent)
{
QLabel *reasonLabel = new QLabel(tr("&Reason for shutdown:"));
reasonEdit = new QLineEdit;
reasonLabel->setBuddy(reasonEdit);
QLabel *minutesLabel = new QLabel(tr("&Time until shutdown (minutes):"));
minutesEdit = new QSpinBox;
minutesLabel->setBuddy(minutesEdit);
minutesEdit->setMinimum(0);
minutesEdit->setValue(5);
QPushButton *okButton = new QPushButton(tr("&OK"));
okButton->setAutoDefault(true);
okButton->setDefault(true);
connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
QPushButton *cancelButton = new QPushButton(tr("&Cancel"));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addStretch();
buttonLayout->addWidget(okButton);
buttonLayout->addWidget(cancelButton);
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget(reasonLabel, 0, 0);
mainLayout->addWidget(reasonEdit, 0, 1);
mainLayout->addWidget(minutesLabel, 1, 0);
mainLayout->addWidget(minutesEdit, 1, 1);
mainLayout->addLayout(buttonLayout, 2, 0, 1, 2);
setLayout(mainLayout);
setWindowTitle(tr("Shut down server"));
}
示例9: QPushButton
QPushButton *ScriptDebugger::createButton(const QString &text, const char *slot, QWidget *parent)
{
QPushButton *button = new QPushButton(text, parent);
connect(button, SIGNAL(pressed()), this, slot);
button->setDefault(false);
button->setAutoDefault(false);
return button;
}
示例10: QDialog
RequestDetailsDlg::RequestDetailsDlg(Request* request, QWidget *parent)
: QDialog(parent)
,m_request(request)
,m_gist(new Gist(parent))
{
connect(m_gist, SIGNAL(published(QString)), this, SLOT(slotGistUrl(QString)));
QGridLayout *gridLayout = new QGridLayout(this);
QHBoxLayout *phLayout = new QHBoxLayout;
QPushButton *cliboard = new QPushButton(QIcon(":/clipboard_32.png"), "", this);
cliboard->setAutoDefault(false);
cliboard->setToolTip(tr("Copy details of request/response to clipboard"));
cliboard->setWhatsThis(tr("Send request/response to cliboard"));
connect(cliboard, SIGNAL(clicked()), this, SLOT(slotSendToBuffer()));
QPushButton *share = new QPushButton(QIcon(":/cloud302_32.png"), "", this);
share->setAutoDefault(false);
share->setToolTip(tr("Share request at gist"));
share->setWhatsThis(tr("Share request at gist"));
connect(share, SIGNAL(clicked()), this, SLOT(slotSendToGist()));
phLayout->addWidget(cliboard);
phLayout->addSpacing(2);
phLayout->addWidget(share);
m_viewRequest = new QTextEdit(this);
m_viewRequest->setFont(QFont("Monospace"));
m_viewRequest->setReadOnly(true);
m_viewRequest->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
m_viewRequest->setHtml(m_request->requestToHtml());
m_viewResponse = new QTextEdit(this);
m_viewResponse->setFont(QFont("Monospace"));
m_viewResponse->setReadOnly(true);
m_viewResponse->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
m_viewResponse->setHtml(m_request->responseToHtml());
gridLayout->addItem(phLayout, 0, 0, 1, 2, Qt::AlignLeft);
gridLayout->addWidget(m_viewRequest, 1, 0, 1, 1);
gridLayout->addWidget(m_viewResponse, 1, 1, 1, 1);
gridLayout->setContentsMargins(0,0,0,0);
gridLayout->setMargin(0);
resize(900, 500);
}
示例11: initMinGreekChars
void symbolDialog::initMinGreekChars()
{
for (int i=0;i<25;i++)
{
QPushButton *btn = new QPushButton(QChar(i+0x3B1), GroupBox1, 0);
btn->setMaximumWidth(30);
btn->setFlat ( true );
btn->setAutoDefault (false);
}
}
示例12: initNumberSymbols
void SymbolDialog::initNumberSymbols() {
int i, counter = 0;
for (i = 0; i <= (0x216B - 0x2153); i++, counter++) {
QPushButton *btn = new QPushButton(QString(QChar(i + 0x2153)));
btn->setMaximumWidth(40);
btn->setFlat(true);
btn->setAutoDefault(false);
buttons->addButton(btn, counter + 1);
gridLayout->addWidget(btn, counter / 8, counter % 8);
}
for (i = 0; i <= (0x217B - 0x2170); i++, counter++) {
QPushButton *btn = new QPushButton(QString(QChar(i + 0x2170)));
btn->setMaximumWidth(40);
btn->setFlat(true);
btn->setAutoDefault(false);
buttons->addButton(btn, counter + 1);
gridLayout->addWidget(btn, counter / 8, counter % 8);
}
numButtons = counter;
}
示例13: initLowerGreekChars
void SymbolDialog::initLowerGreekChars() {
int counter = 0;
for (int i = 0; i <= (0x3C9 - 0x3B1); i++, counter++) {
QPushButton *btn = new QPushButton(QString(QChar(i + 0x3B1)));
btn->setMaximumWidth(40);
btn->setFlat(true);
btn->setAutoDefault(false);
buttons->addButton(btn, counter + 1);
gridLayout->addWidget(btn, counter / 5, counter % 5);
}
}
示例14: showEvent
void PhDialogButtonBox::showEvent(QShowEvent *)
{
// Unset the Cancel button from default
QPushButton * cancelBtn = this->button(QDialogButtonBox::Cancel);
if(cancelBtn) {
cancelBtn->setAutoDefault(false);
cancelBtn->setDefault(false);
cancelBtn->setText(tr("Cancel"));
PHDEBUG << "Set cancel";
}
// Set the Ok Button to default
QPushButton * okBtn = this->button(QDialogButtonBox::Ok);
if(okBtn) {
okBtn->setAutoDefault(true);
okBtn->setDefault(true);
okBtn->setText(tr("Ok"));
PHDEBUG << "Set Ok";
}
}
示例15: initArrowSymbols
void SymbolDialog::initArrowSymbols()
{
int i, counter = 0;
for ( i=0 ; i <= (0x219B-0x2190) ; i++,counter++ )
{
QPushButton *btn = new QPushButton(QString(QChar(i+0x2190)));
btn->setMaximumWidth(40);
btn->setFlat ( true );
btn->setAutoDefault (false);
buttons->addButton(btn,counter+1);
gridLayout->addWidget(btn,counter/6,counter%6);
}
for ( i=0 ; i <= (0x21A7-0x21A4) ; i++,counter++ )
{
QPushButton *btn = new QPushButton(QString(QChar(i+0x21A4)));
btn->setMaximumWidth(40);
btn->setFlat ( true );
btn->setAutoDefault (false);
buttons->addButton(btn,counter+1);
gridLayout->addWidget(btn,counter/6,counter%6);
}
for ( i=0 ; i <= (0x21D5-0x21CD) ; i++,counter++ )
{
QPushButton *btn = new QPushButton(QString(QChar(i+0x21CD)));
btn->setMaximumWidth(40);
btn->setFlat ( true );
btn->setAutoDefault (false);
buttons->addButton(btn,counter+1);
gridLayout->addWidget(btn,counter/6,counter%6);
}
for ( i=0 ; i <= (0x21E9-0x21E6) ; i++,counter++ )
{
QPushButton *btn = new QPushButton(QString(QChar(i+0x21E6)));
btn->setMaximumWidth(40);
btn->setFlat ( true );
btn->setAutoDefault (false);
buttons->addButton(btn,counter+1);
gridLayout->addWidget(btn,counter/6,counter%6);
}
numButtons = counter;
}