本文整理汇总了C++中QStyleOptionToolButton类的典型用法代码示例。如果您正苦于以下问题:C++ QStyleOptionToolButton类的具体用法?C++ QStyleOptionToolButton怎么用?C++ QStyleOptionToolButton使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QStyleOptionToolButton类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: p
void QDockWidgetTitleButton::paintEvent(QPaintEvent *)
{
QPainter p(this);
QStyleOptionToolButton opt;
opt.init(this);
opt.state |= QStyle::State_AutoRaise;
if (style()->styleHint(QStyle::SH_DockWidget_ButtonsHaveFrame, 0, this))
{
if (isEnabled() && underMouse() && !isChecked() && !isDown())
opt.state |= QStyle::State_Raised;
if (isChecked())
opt.state |= QStyle::State_On;
if (isDown())
opt.state |= QStyle::State_Sunken;
style()->drawPrimitive(QStyle::PE_PanelButtonTool, &opt, &p, this);
}
opt.icon = icon();
opt.subControls = 0;
opt.activeSubControls = 0;
opt.features = QStyleOptionToolButton::None;
opt.arrowType = Qt::NoArrow;
int size = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this);
opt.iconSize = QSize(size, size);
style()->drawComplexControl(QStyle::CC_ToolButton, &opt, &p, this);
}
示例2: QTabBar
ToolWindowManagerTabBar::ToolWindowManagerTabBar(QWidget *parent) : QTabBar(parent)
{
m_tabsClosable = false;
setMouseTracking(true);
m_area = qobject_cast<ToolWindowManagerArea *>(parent);
// Workaround for extremely dodgy KDE behaviour - by default the KDE theme will install event
// filters on various widgets such as QTabBar and any descendents, and if a click is detected on
// them that isn't on a tab it will immediately start moving the window, interfering with our own
// click-to-drag behaviour.
setProperty("_kde_no_window_grab", true);
QStyleOptionToolButton buttonOpt;
int size = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this);
buttonOpt.initFrom(parentWidget());
buttonOpt.iconSize = QSize(size, size);
buttonOpt.subControls = 0;
buttonOpt.activeSubControls = 0;
buttonOpt.features = QStyleOptionToolButton::None;
buttonOpt.arrowType = Qt::NoArrow;
buttonOpt.state |= QStyle::State_AutoRaise;
// TODO make our own pin icon, that is pinned/unpinned
m_pin.icon = style()->standardIcon(QStyle::SP_TitleBarNormalButton, &buttonOpt, this);
m_close.icon = style()->standardIcon(QStyle::SP_TitleBarCloseButton, &buttonOpt, this);
m_pin.hover = m_pin.clicked = false;
m_close.hover = m_close.clicked = false;
}
示例3: paintEvent
void QColorPickerTool::paintEvent ( QPaintEvent * )
{
QStyleOptionToolButton option;
option.initFrom( this );
option.features = QStyleOptionToolButton::HasMenu;
//option.state = this->style()->stat
QPixmap icon( 10, 10 );
QPainter iconPainter( &icon );
iconPainter.fillRect( 0, 0, 10, 10, _selectedColor );
//option.icon = icon;
QPainter painter ( this );
//option.text = "COLOR";
option.text = text();
//painter.fillRect( 0, 0, 10, 10, _selectedColor );
//painter.setPen( _selectedColor );
//painter.drawText( 0 ,20, "A" );
//this->setIcon( icon );
style()->drawComplexControl( QStyle::CC_ToolButton, &option, &painter, this );
}
示例4: sp
bool UIControllerSetting::eventFilter( QObject* object, QEvent* event )
{
if ( event->type() == QEvent::Paint )
{
QToolButton* tb = qobject_cast<QToolButton*>( object );
if ( tb )
{
if ( tb->isChecked() )
{
QStylePainter sp( tb );
QStyleOptionToolButton options;
options.initFrom( tb );
options.arrowType = Qt::NoArrow;
options.features = QStyleOptionToolButton::None;
options.icon = tb->icon();
options.iconSize = tb->iconSize();
options.state = QStyle::State_Enabled | QStyle::State_HasFocus | QStyle::State_On | QStyle::State_AutoRaise;
sp.drawComplexControl( QStyle::CC_ToolButton, options );
return true;
}
}
}
return false;
}
示例5: paintEvent
void GuiToolButton::paintEvent(QPaintEvent *e)
{
QStyleOptionToolButton option;
option.initFrom(this);
QPainter painter(this);
if (option.state & QStyle::State_MouseOver)
painter.drawPixmap(e->rect(), QPixmap(":/images/menu-hover.png"));
else
painter.drawPixmap(e->rect(), QPixmap(":/images/drag.png"));
}
示例6: QRect
/*!
\internal
Returns the rectangle occupied by this button, depending on \a
child.
*/
QRect QAccessibleToolButton::rect(int child) const
{
if (!toolButton()->isVisible())
return QRect();
if (!child)
return QAccessibleButton::rect(child);
QStyleOptionToolButton opt;
opt.init(widget());
QRect subrect = widget()->style()->subControlRect(QStyle::CC_ToolButton, &opt,
QStyle::SC_ToolButtonMenu, toolButton());
if (child == ButtonExecute)
subrect = QRect(0, 0, subrect.x(), widget()->height());
QPoint ntl = widget()->mapToGlobal(subrect.topLeft());
subrect.moveTopLeft(ntl);
return subrect;
}
示例7: sizeof
QSize
kMyMoneyCalendar::sizeHint() const
{
QSize tableSize = table->sizeHint();
QWidget *buttons[] = {
styleControl,
yearBackward,
monthBackward,
selectMonth,
selectYear,
monthForward,
yearForward,
d->closeButton,
d->userButton1,
d->userButton2
};
const int NoOfButtons = sizeof(buttons) / sizeof(buttons[0]);
QSize sizes[NoOfButtons];
int cx = 0, cy = 0, count;
// ----- store the size hints:
for (count = 0; count < NoOfButtons; ++count) {
if (buttons[count])
sizes[count] = buttons[count]->sizeHint();
else
sizes[count] = QSize(0, 0);
if (buttons[count] == selectMonth) {
QStyleOptionToolButton opt;
opt.initFrom(selectMonth);
QSize metricBound = style()->sizeFromContents(QStyle::CT_ToolButton, &opt, maxMonthRect);
cx += qMax(metricBound.width(), maxMonthRect.width() + 2 * QApplication::style()->pixelMetric(QStyle::PM_ButtonMargin));
} else {
cx += sizes[count].width();
}
cy = qMax(sizes[count].height(), cy);
}
// ----- calculate width hint:
cx = qMax(cx, tableSize.width()); // line edit ignored
// ----- calculate height hint:
cy += tableSize.height() + line->sizeHint().height();
return QSize(cx, cy);
}
示例8: p
void ToolWindowManagerTabBar::paintEvent(QPaintEvent *event)
{
if(useMinimalBar())
{
if(floatingWindowChild())
return;
QStylePainter p(this);
QStyleOptionDockWidget option;
option.initFrom(parentWidget());
option.rect = m_titleRect;
option.title = tabText(0);
option.closable = m_tabsClosable;
option.movable = false;
// we only set floatable true so we can hijack the float button for our own pin/auto-hide button
option.floatable = true;
Shape s = shape();
option.verticalTitleBar =
s == RoundedEast || s == TriangularEast || s == RoundedWest || s == TriangularWest;
p.drawControl(QStyle::CE_DockWidgetTitle, option);
int size = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this);
QStyleOptionToolButton buttonOpt;
buttonOpt.initFrom(parentWidget());
buttonOpt.iconSize = QSize(size, size);
buttonOpt.subControls = 0;
buttonOpt.activeSubControls = 0;
buttonOpt.features = QStyleOptionToolButton::None;
buttonOpt.arrowType = Qt::NoArrow;
buttonOpt.state = QStyle::State_Active | QStyle::State_Enabled | QStyle::State_AutoRaise;
buttonOpt.rect = m_pin.rect;
buttonOpt.icon = m_pin.icon;
ToolWindowManager::ToolWindowProperty props =
m_area->m_manager->toolWindowProperties(m_area->widget(0));
bool tabClosable = (props & ToolWindowManager::HideCloseButton) == 0;
if(!tabClosable && !m_pin.rect.isEmpty())
buttonOpt.rect = m_close.rect;
QStyle::State prevState = buttonOpt.state;
if(m_pin.clicked)
buttonOpt.state |= QStyle::State_Sunken;
else if(m_pin.hover)
buttonOpt.state |= QStyle::State_Raised | QStyle::State_MouseOver;
if(style()->styleHint(QStyle::SH_DockWidget_ButtonsHaveFrame, 0, this))
{
style()->drawPrimitive(QStyle::PE_PanelButtonTool, &buttonOpt, &p, this);
}
style()->drawComplexControl(QStyle::CC_ToolButton, &buttonOpt, &p, this);
if(m_tabsClosable && tabClosable)
{
buttonOpt.rect = m_close.rect;
buttonOpt.icon = m_close.icon;
buttonOpt.state = prevState;
if(m_close.clicked)
buttonOpt.state |= QStyle::State_Sunken;
else if(m_close.hover)
buttonOpt.state |= QStyle::State_Raised | QStyle::State_MouseOver;
style()->drawPrimitive(QStyle::PE_IndicatorTabClose, &buttonOpt, &p, this);
}
return;
}
QTabBar::paintEvent(event);
}