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


C++ QPushButton::setAutoDefault方法代码示例

本文整理汇总了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:"));
    }
}
开发者ID:Pik-9,项目名称:qTox,代码行数:60,代码来源:gui.cpp

示例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();
}
开发者ID:Brackets,项目名称:rstudio,代码行数:30,代码来源:DesktopUpdateAvailableDialog.cpp

示例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);
}
开发者ID:Jakub-Ciecierski,项目名称:InfinityCAD,代码行数:30,代码来源:surface_settings_dialog.cpp

示例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)));
}
开发者ID:NikhilNJ,项目名称:screenplay-dx,代码行数:15,代码来源:qtgradientdialog.cpp

示例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");
}
开发者ID:sansajn,项目名称:aexplor,代码行数:30,代码来源:mkdir_dialog.cpp

示例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 );
}
开发者ID:Timmmm,项目名称:lastfm-desktop,代码行数:34,代码来源:ShareDialog.cpp

示例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();
}
开发者ID:TeamKami,项目名称:KamiCmd,代码行数:32,代码来源:qwwtipwidget.cpp

示例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"));
}
开发者ID:MasterCockatrice,项目名称:Cockatrice,代码行数:34,代码来源:tab_admin.cpp

示例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;
}
开发者ID:,项目名称:,代码行数:8,代码来源:

示例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);
}
开发者ID:jacmoe,项目名称:qrestclient,代码行数:45,代码来源:requestdetailsdlg.cpp

示例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);
	}
}
开发者ID:BackupTheBerlios,项目名称:qtiplot-svn,代码行数:10,代码来源:symbolDialog.cpp

示例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;
}
开发者ID:DanNixon,项目名称:mantid,代码行数:20,代码来源:SymbolDialog.cpp

示例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);
  }
}
开发者ID:DanNixon,项目名称:mantid,代码行数:11,代码来源:SymbolDialog.cpp

示例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";
	}
}
开发者ID:EMATech,项目名称:Joker,代码行数:20,代码来源:PhDialogButtonBox.cpp

示例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;
}
开发者ID:BackupTheBerlios,项目名称:qtiplot-svn,代码行数:41,代码来源:SymbolDialog.cpp


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