本文整理汇总了C++中QAbstractButton::setFocusPolicy方法的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractButton::setFocusPolicy方法的具体用法?C++ QAbstractButton::setFocusPolicy怎么用?C++ QAbstractButton::setFocusPolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAbstractButton
的用法示例。
在下文中一共展示了QAbstractButton::setFocusPolicy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QDialog
// constructor
LineObjectDialog::LineObjectDialog (QWidget * parent):
QDialog (parent), ui (new Ui::LineObjectDialog)
{
QAbstractButton *button;
ui->setupUi (this);
this->setWindowFlags(Qt::CustomizeWindowHint);
color = Qt::white;
pixmap = new QPixmap (16, 16);
icon = new QIcon;
pixmap->fill (color);
icon->addPixmap (*pixmap, QIcon::Normal, QIcon::On);
ui->colorButton->setIcon (*icon);
#ifdef Q_OS_WIN
colorDialog = new QColorDialog (this);
#else
colorDialog = new QColorDialog; // (this);
#endif
colorDialog->setModal (true);
foreach (button, ui->buttonBox->buttons ())
button->setFocusPolicy (Qt::NoFocus);
connect(ui->colorButton, SIGNAL(clicked (bool)), this, SLOT(color_clicked(void)));
connect (colorDialog, SIGNAL (accepted ()), this, SLOT (colorDialog_accepted ()));
connect(ui->buttonBox, SIGNAL(accepted ()), this, SLOT(ok_clicked ()));
connect(ui->buttonBox, SIGNAL(rejected ()), this, SLOT(cancel_clicked ()));
correctWidgetFonts (this);
}
示例2: QToolButton
QAbstractButton *FormMultiWidget::makeButton(const QIcon &icon, const char *slot)
{
QAbstractButton *btn = new QToolButton(this);
btn->setIcon(icon);
btn->setFixedSize(icon.availableSizes().first() /* + something */);
btn->setFocusPolicy(Qt::NoFocus);
connect(btn, SIGNAL(clicked()), slot);
return btn;
}
示例3: fixFocusPolicy
void QAbstractButtonPrivate::fixFocusPolicy()
{
Q_Q(QAbstractButton);
#ifndef QT_NO_BUTTONGROUP
if (!group && !autoExclusive)
#else
if (!autoExclusive)
#endif
return;
QList<QAbstractButton *> buttonList = queryButtonList();
for (int i = 0; i < buttonList.count(); ++i) {
QAbstractButton *b = buttonList.at(i);
if (!b->isCheckable())
continue;
b->setFocusPolicy((Qt::FocusPolicy) ((b == q || !q->isCheckable())
? (b->focusPolicy() | Qt::TabFocus)
: (b->focusPolicy() & ~Qt::TabFocus)));
}
}