当前位置: 首页>>代码示例>>C++>>正文


C++ QStyleOptionToolButton类代码示例

本文整理汇总了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);
}
开发者ID:phen89,项目名称:rtqt,代码行数:28,代码来源:qdockwidget.cpp

示例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;
}
开发者ID:cgmb,项目名称:renderdoc,代码行数:33,代码来源:ToolWindowManagerTabBar.cpp

示例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 );

}
开发者ID:HamedMasafi,项目名称:QtReport,代码行数:25,代码来源:qreportcolorpicker.cpp

示例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;
}
开发者ID:cano159,项目名称:yabause,代码行数:29,代码来源:UIControllerSetting.cpp

示例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"));
}
开发者ID:AmiditeX,项目名称:qutty,代码行数:10,代码来源:GuiMainWindow.cpp

示例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;
}
开发者ID:RS102839,项目名称:qt,代码行数:25,代码来源:simplewidgets.cpp

示例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);
}
开发者ID:CGenie,项目名称:kmymoney,代码行数:42,代码来源:kmymoneycalendar.cpp

示例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);
}
开发者ID:cgmb,项目名称:renderdoc,代码行数:81,代码来源:ToolWindowManagerTabBar.cpp


注:本文中的QStyleOptionToolButton类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。