本文整理汇总了C++中QToolButton::setFocusPolicy方法的典型用法代码示例。如果您正苦于以下问题:C++ QToolButton::setFocusPolicy方法的具体用法?C++ QToolButton::setFocusPolicy怎么用?C++ QToolButton::setFocusPolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QToolButton
的用法示例。
在下文中一共展示了QToolButton::setFocusPolicy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createWidget
QWidget* ToolAction::createWidget( QWidget *parent )
{
QToolBar *toolBar = qobject_cast< QToolBar * >( parent );
if ( !toolBar )
return 0;
QToolButton *button = new QToolButton( toolBar );
button->setAutoRaise( true );
button->setFocusPolicy( Qt::NoFocus );
button->setIconSize( toolBar->iconSize() );
button->setToolButtonStyle( toolBar->toolButtonStyle() );
button->setPopupMode( QToolButton::DelayedPopup );
button->setMenu( new QMenu( button ) );
button->setCheckable( true );
connect(toolBar, &QToolBar::iconSizeChanged, button, &QToolButton::setIconSize);
connect(toolBar, &QToolBar::toolButtonStyleChanged, button, &QToolButton::setToolButtonStyle);
connect(button, &QToolButton::triggered, toolBar, &QToolBar::actionTriggered);
connect( button->menu(), &QMenu::triggered, this, &ToolAction::slotNewDefaultAction );
m_buttons.append( button );
if ( !m_actions.isEmpty() )
{
button->setDefaultAction( m_actions.first() );
foreach ( QAction *action, m_actions )
{
button->menu()->addAction( action );
if ( action->isChecked() )
button->setDefaultAction( action );
}
示例2: createFormatToolBar
QToolBar* MainWindow::createFormatToolBar()
{
QToolBar *pFormatBar = new QToolBar();
pFormatBar->setWindowTitle( "Format Bar" );
m_pCmbFont = new QFontComboBox;
m_pCmbFont->setEditable( false );
m_pCmbFont->setFocusPolicy( Qt::NoFocus );
m_pCmbFontPointSize = new QComboBox;
updateFontPointSize( m_pCmbFont->currentText() );
m_pCmbFontPointSize->setFocusPolicy( Qt::NoFocus );
QToolButton *pBtnMoreOptions = new QToolButton;
pBtnMoreOptions->setText( "More..." );
pBtnMoreOptions->setStyleSheet( "border: 1px solid #000000" );
pBtnMoreOptions->setFixedHeight( 20 );
pBtnMoreOptions->setFocusPolicy( Qt::NoFocus );
pFormatBar->addWidget( m_pCmbFont );
pFormatBar->addWidget( m_pCmbFontPointSize );
pFormatBar->addWidget( pBtnMoreOptions );
connect( m_pCmbFont, SIGNAL(currentIndexChanged(int)), this, SLOT(onFontFamilyChanged()) );
connect( m_pCmbFontPointSize, SIGNAL(currentIndexChanged(int)), this, SLOT(onFontPointSizeChanged()) );
connect( pBtnMoreOptions, SIGNAL(clicked()), this, SLOT(onFormatMoreBtnClicked()) );
return pFormatBar;
}
示例3: createWidget
QWidget *KToolBarPopupAction::createWidget(QWidget *_parent)
{
QToolBar *parent = qobject_cast<QToolBar *>(_parent);
if (!parent) {
return QWidgetAction::createWidget(_parent);
}
QToolButton *button = new QToolButton(parent);
button->setAutoRaise(true);
button->setFocusPolicy(Qt::NoFocus);
button->setIconSize(parent->iconSize());
button->setToolButtonStyle(parent->toolButtonStyle());
button->setDefaultAction(this);
connect(parent, &QToolBar::iconSizeChanged,
button, &QAbstractButton::setIconSize);
connect(parent, &QToolBar::toolButtonStyleChanged,
button, &QToolButton::setToolButtonStyle);
connect(button, &QToolButton::triggered,
parent, &QToolBar::actionTriggered);
if (d->delayed)
if (d->stickyMenu) {
button->setPopupMode(QToolButton::MenuButtonPopup);
} else {
button->setPopupMode(QToolButton::DelayedPopup);
}
else {
button->setPopupMode(QToolButton::InstantPopup);
}
return button;
}
示例4: QToolButton
WNavigationTreeCaption::WNavigationTreeCaption()
{
QToolButton * pwButtonUndock = new QToolButton(this);
pwButtonUndock->setToolTip("Float / Unfloat");
#if 1
pwButtonUndock->setStyleSheet("QToolButton { border: none; padding: 3px; }");
#else
pwButtonUndock->setStyleSheet("QToolButton { border: none; padding: 0px; }");
#endif
QPixmap oPixmap = style()->standardPixmap(QStyle::SP_TitleBarNormalButton);
pwButtonUndock->setIcon(oPixmap);
// pwButtonUndock->setMaximumSize(oPixmap.size());
pwButtonUndock->setCursor(Qt::ArrowCursor);
pwButtonUndock->setFocusPolicy(Qt::ClickFocus);
QHBoxLayout * layout = new QHBoxLayout(this);
layout->setMargin(0);
// layout->setSpacing(10);
// layout->addStretch();
#if 0
layout->addWidget(g_pwButtonStatusOfNavigationTree, Qt::AlignLeft | Qt::AlignHCenter);
#endif
layout->addWidget(g_pwButtonSwitchProfile); // , Qt::AlignLeft | Qt::AlignHCenter);
//layout->addWidget(new QWidget);
layout->addStretch();
//layout->addWidget(pwButtonUndock, Qt::AlignRight | Qt::AlignHCenter);
layout->addWidget(pwButtonUndock);
setLayout(layout);
connect(pwButtonUndock, SIGNAL(clicked()), g_pwNavigationTree, SLOT(SL_ToggleDocking()));
setCursor(Qt::OpenHandCursor); // This cursor shows to the user he/she may drag the widget to undock the Navigation Tree
}
示例5: QToolButton
/*!
\internal
\brief Creates a tool button using given action.
This action will set as the default action instead of adding into its action list.
@return the pointer to a QToolButton instance by "new" operation
*/
QToolButton * Ui::MainWindow::createToolButton(QAction *action, QWidget *parent /* = 0 */)
{
QToolButton *button = new QToolButton(parent);
button->setDefaultAction(action);
button->setAutoRaise(true);
button->setFocusPolicy(Qt::NoFocus);
return button;
}
示例6: createAction
QToolButton* KexiRecordNavigator::createAction(const KGuiItem& item)
{
QToolButton *toolButton;
d->lyr->addWidget(toolButton = new KexiSmallToolButton(item.icon(), QString(), this), 0, Qt::AlignVCenter);
toolButton->setFocusPolicy(Qt::NoFocus);
toolButton->setToolTip(item.toolTip());
toolButton->setWhatsThis(item.whatsThis());
return toolButton;
}
示例7: prepareErrorPane
void UIDesktopPanePrivate::prepareErrorPane()
{
if (m_pErrBox)
return;
/* Create error pane: */
m_pErrBox = new QWidget;
/* Create main layout: */
QVBoxLayout *pMainLayout = new QVBoxLayout(m_pErrBox);
#if defined(VBOX_WS_MAC)
pMainLayout->setContentsMargins(4, 5, 5, 5);
#elif defined(VBOX_WS_WIN)
pMainLayout->setContentsMargins(3, 5, 5, 0);
#elif defined(VBOX_WS_X11)
pMainLayout->setContentsMargins(0, 5, 5, 5);
#endif
pMainLayout->setSpacing(10);
/* Create error label: */
m_pErrLabel = new QLabel(m_pErrBox);
m_pErrLabel->setWordWrap(true);
m_pErrLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
pMainLayout->addWidget(m_pErrLabel);
/* Create error text-browser: */
m_pErrText = new QTextBrowser(m_pErrBox);
m_pErrText->setFocusPolicy(Qt::StrongFocus);
m_pErrText->document()->setDefaultStyleSheet("a { text-decoration: none; }");
pMainLayout->addWidget(m_pErrText);
/* If refresh action was set: */
if (m_pRefreshAction)
{
/* Create refresh button: */
m_pRefreshButton = new QToolButton(m_pErrBox);
m_pRefreshButton->setFocusPolicy(Qt::StrongFocus);
/* Create refresh button layout: */
QHBoxLayout *pButtonLayout = new QHBoxLayout;
pMainLayout->addLayout(pButtonLayout);
pButtonLayout->addStretch();
pButtonLayout->addWidget(m_pRefreshButton);
/* Connect refresh button: */
connect(m_pRefreshButton, SIGNAL(clicked()), m_pRefreshAction, SIGNAL(triggered()));
}
pMainLayout->addStretch();
/* Add into the stack: */
addWidget(m_pErrBox);
/* Retranslate finally: */
retranslateUi();
}
示例8: QToolButton
QToolButton *
PlayerWidget::createToolButton(QWidget *parent, const char *name, int size)
{
QToolButton *toolButton = new QToolButton(parent);
toolButton->setObjectName(name);
toolButton->setMinimumSize(size, size);
toolButton->setIconSize(size >= 32 ? QSize(size - 6, size - 6) : QSize(size, size));
toolButton->setAutoRaise(true);
toolButton->setFocusPolicy(Qt::NoFocus);
return toolButton;
}
示例9: QToolButton
QAbstractButton *StartTab::addShortcut(const QString &name, const QIcon &icon, QWidget *parent)
{
// QPushButton has visual problems with big icons
QToolButton *button = new QToolButton(parent);
button->setText(name);
button->setIcon(icon);
button->setFocusPolicy(Qt::NoFocus);
button->setIconSize(QSize(48, 48));
button->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
return button;
}
示例10: createGUI
void NBOdfOgle::createGUI() {
QHBoxLayout *lblBtnLyt = new QHBoxLayout();
QVBoxLayout *widgetLyt = new QVBoxLayout();
QVBoxLayout *baseLyt = new QVBoxLayout();
QLabel *lbl = new QLabel( "<tt><b>" + path + "</b></tt>" );
QToolButton *openBtn = new QToolButton();
openBtn->setIcon( QIcon( ":/icons/maximize.png" ) );
openBtn->setAutoRaise( true );
openBtn->setFocusPolicy( Qt::NoFocus );
QWidget *baseWidget = new QWidget();
baseWidget->setObjectName( tr( "guiBase" ) );
connect( openBtn, SIGNAL( clicked() ), this, SLOT( openInExternal() ) );
peekWidgetBase = new QTextBrowser();
// Some basic settings
peekWidgetBase->setTabStopWidth( 9 * 4 );
peekWidgetBase->setFont( QFont( "Courier 10 Pitch", 9 ) );
peekWidgetBase->setAlignment( Qt::AlignLeft );
peekWidgetBase->setAcceptRichText( false );
peekWidgetBase->setReadOnly( true );
// Remove Horizontal Scrollbar, put a Vertical one
peekWidgetBase->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
peekWidgetBase->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );
// Enable word wrap
peekWidgetBase->setWordWrapMode( QTextOption::WrapAtWordBoundaryOrAnywhere );
peekWidgetBase->setObjectName( tr( "previewBase" ) );
lblBtnLyt->addWidget( lbl );
lblBtnLyt->addStretch( 0 );
lblBtnLyt->addWidget( openBtn );
widgetLyt->addLayout( lblBtnLyt );
widgetLyt->addWidget( peekWidgetBase );
baseWidget->setLayout( widgetLyt );
baseLyt->addWidget( baseWidget );
baseLyt->setContentsMargins( 0, 0, 0, 0 );
setLayout( baseLyt );
peekWidgetBase->setFocus();
};
示例11:
QToolButton *addToolButton(QString const &label, QIcon const &icon)
{
QToolButton *tb = new QToolButton;
tb->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
tb->setFocusPolicy(Qt::NoFocus);
tb->setText(label);
tb->setIcon(icon);
tb->setCheckable(true);
#ifdef MACOSX
// Tighter spacing, please.
tb->setStyleSheet("padding-bottom:-5px");
#endif
tools->addWidget(tb);
return tb;
}
示例12: addAction
void SideBarGroup::addAction(QAction* action)
{
int size = KIconLoader::global()->currentSize(KIconLoader::Small);
QToolButton* button = new SideBarButton();
button->setFocusPolicy(Qt::NoFocus);
button->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
button->setAutoRaise(true);
button->setDefaultAction(action);
button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
button->setIconSize(QSize(size, size));
if (action->menu()) {
button->setPopupMode(QToolButton::InstantPopup);
}
addWidget(button);
}
示例13: QWidget
ActionOptionWidget::ActionOptionWidget(CellToolBase* cellTool, const QDomElement& e, QWidget *parent) :
QWidget(parent)
{
QString name = e.attribute("name");
setObjectName(name);
setWindowTitle(i18n(name.toLatin1()));
QLayout* layout = new GroupFlowLayout(this);//QBoxLayout(QBoxLayout::TopToBottom, this);
for (QDomElement group = e.firstChildElement("group"); !group.isNull(); group = group.nextSiblingElement("group")) {
QHBoxLayout *groupLayout = new QHBoxLayout();
layout->addItem(groupLayout);
// In each group there are a number of actions that will be layouted together.
for (QDomElement action = group.firstChildElement("action"); !action.isNull(); action = action.nextSiblingElement("action")) {
QString actionName = action.attribute("name");
QAction* a = cellTool->action(actionName);
if (!a) {
kWarning() << "unknown action" << actionName << "in CellToolOptionWidgets.xml";
continue;
}
QWidget* w = qobject_cast<QWidgetAction*>(a) ? qobject_cast<QWidgetAction*>(a)->requestWidget(this) : 0;
if (w && w->inherits("QFontComboBox")) {
w->setMinimumWidth(w->minimumWidth() / 2);
}
if (!w) {
QToolButton* b = new QToolButton(this);
b->setFocusPolicy(Qt::NoFocus);
b->setDefaultAction(a);
w = b;
}
if (w) {
groupLayout->addWidget(w);
}
}
}
// The following widget activates a special feature in the
// ToolOptionsDocker that makes the components of the widget align
// to the top if there is extra space.
QWidget *specialSpacer = new QWidget(this);
specialSpacer->setObjectName("SpecialSpacer");
layout->addWidget(specialSpacer);
}
示例14: addToolbarItem
void ZLQtApplicationWindow::addToolbarItem(ZLToolbar::ItemPtr item) {
QToolBar *tb = toolbar(type(*item));
QAction *action = 0;
switch (item->type()) {
case ZLToolbar::Item::PLAIN_BUTTON:
case ZLToolbar::Item::TOGGLE_BUTTON:
action = new ZLQtToolBarAction(this, (ZLToolbar::AbstractButtonItem&)*item);
tb->addAction(action);
break;
case ZLToolbar::Item::MENU_BUTTON:
{
ZLToolbar::MenuButtonItem &buttonItem = (ZLToolbar::MenuButtonItem&)*item;
QToolButton *button = new QToolButton(tb);
button->setFocusPolicy(Qt::NoFocus);
button->setDefaultAction(new ZLQtToolBarAction(this, buttonItem));
button->setMenu(new QMenu(button));
button->setPopupMode(QToolButton::MenuButtonPopup);
action = tb->addWidget(button);
myMenuButtons[&buttonItem] = button;
shared_ptr<ZLPopupData> popupData = buttonItem.popupData();
myPopupIdMap[&buttonItem] =
popupData.isNull() ? (size_t)-1 : (popupData->id() - 1);
break;
}
case ZLToolbar::Item::TEXT_FIELD:
case ZLToolbar::Item::SEARCH_FIELD:
{
ZLToolbar::ParameterItem &textFieldItem =
(ZLToolbar::ParameterItem&)*item;
LineEditParameter *para = new LineEditParameter(tb, *this, textFieldItem);
addVisualParameter(textFieldItem.parameterId(), para);
action = para->action();
break;
}
case ZLToolbar::Item::SEPARATOR:
action = tb->addSeparator();
break;
}
if (action != 0) {
myActions[&*item] = action;
}
}
示例15: QLineEdit
FilterWidget::FilterWidget(QWidget *parent)
: QLineEdit(parent)
, m_patternGroup(new QActionGroup(this))
{
setClearButtonEnabled(true);
connect(this, SIGNAL(textChanged(QString)), this, SIGNAL(filterChanged()));
QMenu *menu = new QMenu(this);
m_caseSensitivityAction = menu->addAction(tr("Case Sensitive"));
m_caseSensitivityAction->setCheckable(true);
connect(m_caseSensitivityAction, SIGNAL(toggled(bool)), this, SIGNAL(filterChanged()));
menu->addSeparator();
m_patternGroup->setExclusive(true);
QAction *patternAction = menu->addAction("Fixed String");
patternAction->setData(QVariant(int(QRegExp::FixedString)));
patternAction->setCheckable(true);
patternAction->setChecked(true);
m_patternGroup->addAction(patternAction);
patternAction = menu->addAction("Regular Expression");
patternAction->setCheckable(true);
patternAction->setData(QVariant(int(QRegExp::RegExp2)));
m_patternGroup->addAction(patternAction);
patternAction = menu->addAction("Wildcard");
patternAction->setCheckable(true);
patternAction->setData(QVariant(int(QRegExp::Wildcard)));
m_patternGroup->addAction(patternAction);
connect(m_patternGroup, SIGNAL(triggered(QAction*)), this, SIGNAL(filterChanged()));
const QIcon icon = QIcon(QPixmap(":/images/find.png"));
QToolButton *optionsButton = new QToolButton;
#ifndef QT_NO_CURSOR
optionsButton->setCursor(Qt::ArrowCursor);
#endif
optionsButton->setFocusPolicy(Qt::NoFocus);
optionsButton->setStyleSheet("* { border: none; }");
optionsButton->setIcon(icon);
optionsButton->setMenu(menu);
optionsButton->setPopupMode(QToolButton::InstantPopup);
QWidgetAction *optionsAction = new QWidgetAction(this);
optionsAction->setDefaultWidget(optionsButton);
addAction(optionsAction, QLineEdit::LeadingPosition);
}