本文整理汇总了C++中QToolButton::sizeHint方法的典型用法代码示例。如果您正苦于以下问题:C++ QToolButton::sizeHint方法的具体用法?C++ QToolButton::sizeHint怎么用?C++ QToolButton::sizeHint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QToolButton
的用法示例。
在下文中一共展示了QToolButton::sizeHint方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QVBoxLayout
PopupButton::PopupButton(QWidget* parent)
{
// this->setFrameStyle(QFrame::Box);
QVBoxLayout* layout = new QVBoxLayout(this);
layout->setMargin(0);
this->setLayout(layout);
// QToolButton* expandButton = new QToolButton(this);
QToolButton* expandButton = new CXSmallToolButton(this);
mShowHeaderButton = expandButton;
this->setFixedSize(expandButton->sizeHint());
QAction* action = new QAction(QIcon(":icons/open_icon_library/layer-lower-3.png"), "Controls", this);
QString tip = "Show Controls";
action->setStatusTip(tip);
action->setWhatsThis(tip);
action->setToolTip(tip);
connect(action, SIGNAL(triggered()), this, SLOT(onTriggered()));
mAction = action;
mShowHeaderButton->setDefaultAction(action);
layout->addWidget(mShowHeaderButton);
action->setCheckable(true);
}
示例2: CreateToolButton
QToolButton* SelectPathWidgetBase::CreateToolButton(const DAVA::String& iconPath)
{
QToolButton* retButton;
retButton = new QToolButton(this);
QIcon icon(iconPath.c_str());
retButton->setIcon(icon);
retButton->setCursor(Qt::ArrowCursor);
retButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
QSize msz = minimumSizeHint();
setStyleSheet(QString("QLineEdit { padding-right: %1px; } ").arg(retButton->sizeHint().width() * 2 + frameWidth));
setMinimumSize(qMax(msz.width(), retButton->sizeHint().height() + frameWidth * 2 + 2),
qMax(msz.height(), retButton->sizeHint().height() + frameWidth * 2 + 2));
return retButton;
}
示例3: if
UBToolbarButtonGroup::UBToolbarButtonGroup(QToolBar *toolBar, const QList<QAction*> &actions)
: QWidget(toolBar)
, mActions(actions)
, mCurrentIndex(-1)
, mDisplayLabel(true)
, mActionGroup(0)
{
Q_ASSERT(actions.size() > 0);
mToolButton = qobject_cast<QToolButton*>(toolBar->layout()->itemAt(0)->widget());
Q_ASSERT(mToolButton);
QVBoxLayout *verticalLayout = new QVBoxLayout(this);
QHBoxLayout *horizontalLayout = new QHBoxLayout();
horizontalLayout->setSpacing(0);
verticalLayout->addStretch();
verticalLayout->addLayout(horizontalLayout);
verticalLayout->addStretch();
mActionGroup = new QActionGroup(this);
mActionGroup->setExclusive(true);
QSize buttonSize;
int i = 0;
foreach(QAction *action, actions)
{
mActionGroup->addAction(action);
QToolButton *button = new QToolButton(this);
mButtons.append(button);
button->setDefaultAction(action);
button->setCheckable(true);
if(i == 0)
{
button->setObjectName("ubButtonGroupLeft");
}
else if (i == actions.size() - 1)
{
button->setObjectName("ubButtonGroupRight");
}
else
{
button->setObjectName("ubButtonGroupCenter");
}
connect(button, SIGNAL(triggered(QAction*)), this, SLOT(selected(QAction*)));
horizontalLayout->addWidget(button);
mLabel = action->text();
buttonSize = button->sizeHint();
i++;
}
示例4: RepaintButtons
void ProgressLineEdit::RepaintButtons ()
{
const int frameWidth = style ()->pixelMetric (QStyle::PM_DefaultFrameWidth);
int rightBorder = 0;
int realBorder = 0;
for (int i = VisibleButtons_.count () - 1; i >= 0; --i)
{
QToolButton *btn = VisibleButtons_ [i];
const QSize& bmSz = btn->sizeHint ();
rightBorder += bmSz.width ();
if (i > 0)
realBorder += bmSz.width ();
btn->move (rect ().right () - frameWidth - rightBorder,
(rect ().bottom () + 1 - bmSz.height ()) / 2);
}
const QMargins& margins = textMargins ();
setTextMargins (margins.left (),
margins.top (),
realBorder + frameWidth,
margins.bottom ());
}