本文整理汇总了C++中QDialogButtonBox::setProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ QDialogButtonBox::setProperty方法的具体用法?C++ QDialogButtonBox::setProperty怎么用?C++ QDialogButtonBox::setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDialogButtonBox
的用法示例。
在下文中一共展示了QDialogButtonBox::setProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processAuthForm
void OpenconnectAuthWidget::processAuthForm(struct oc_auth_form *form)
{
Q_D(OpenconnectAuthWidget);
deleteAllFromLayout(d->ui.loginBoxLayout);
if (form->banner) {
addFormInfo(QLatin1String("dialog-information"), form->banner);
}
if (form->message) {
addFormInfo(QLatin1String("dialog-information"), form->message);
}
if (form->error) {
addFormInfo(QLatin1String("dialog-error"), form->error);
}
struct oc_form_opt *opt;
QFormLayout *layout = new QFormLayout();
QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Fixed);
bool focusSet = false;
for (opt = form->opts; opt; opt = opt->next) {
if (opt->type == OC_FORM_OPT_HIDDEN || IGNORE_OPT(opt)) {
continue;
}
QLabel *text = new QLabel(this);
text->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter);
text->setText(QString(opt->label));
QWidget *widget = 0;
const QString key = QString("form:%1:%2").arg(QLatin1String(form->auth_id)).arg(QLatin1String(opt->name));
const QString value = d->secrets.value(key);
if (opt->type == OC_FORM_OPT_PASSWORD || opt->type == OC_FORM_OPT_TEXT) {
PasswordField *le = new PasswordField(this);
le->setText(value);
if (opt->type == OC_FORM_OPT_PASSWORD) {
le->setPasswordModeEnabled(true);
}
if (!focusSet && le->text().isEmpty()) {
le->setFocus(Qt::OtherFocusReason);
focusSet = true;
}
widget = qobject_cast<QWidget*>(le);
} else if (opt->type == OC_FORM_OPT_SELECT) {
QComboBox *cmb = new QComboBox(this);
struct oc_form_opt_select *sopt = reinterpret_cast<oc_form_opt_select *>(opt);
for (int i = 0; i < sopt->nr_choices; i++) {
cmb->addItem(QString::fromUtf8(FORMCHOICE(sopt, i)->label), QString::fromUtf8(FORMCHOICE(sopt, i)->name));
if (value == QString::fromUtf8(FORMCHOICE(sopt, i)->name)) {
cmb->setCurrentIndex(i);
if (sopt == AUTHGROUP_OPT(form) && i != AUTHGROUP_SELECTION(form)) {
QTimer::singleShot(0, this, &OpenconnectAuthWidget::formGroupChanged);
}
}
}
if (sopt == AUTHGROUP_OPT(form)) {
connect(cmb, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &OpenconnectAuthWidget::formGroupChanged);
}
widget = qobject_cast<QWidget*>(cmb);
}
if (widget) {
widget->setProperty("openconnect_opt", (quintptr)opt);
widget->setSizePolicy(policy);
layout->addRow(text, widget);
}
}
d->ui.loginBoxLayout->addLayout(layout);
d->passwordFormIndex = d->ui.loginBoxLayout->count() - 1;
QDialogButtonBox *box = new QDialogButtonBox(this);
QPushButton *btn = box->addButton(QDialogButtonBox::Ok);
btn->setText(i18n("Login"));
btn->setDefault(true);
d->ui.loginBoxLayout->addWidget(box);
box->setProperty("openconnect_form", (quintptr)form);
connect(box, &QDialogButtonBox::accepted, this, &OpenconnectAuthWidget::formLoginClicked);
}