本文整理汇总了C++中QStyleOption::init方法的典型用法代码示例。如果您正苦于以下问题:C++ QStyleOption::init方法的具体用法?C++ QStyleOption::init怎么用?C++ QStyleOption::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStyleOption
的用法示例。
在下文中一共展示了QStyleOption::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintEvent
void ReleaseDialog::paintEvent(QPaintEvent *event)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
// QPixmap pixmap("./login/images/login_bg.png");
// QWidget::setMask(pixmap.mask());
// QPainter painter(this->parentWidget());
// painter.setPen(Qt::NoPen);
// painter.setBrush(Qt::red);
// painter.drawRect(QRect(10, 10, 50, 80));
}
示例2: paintEvent
void PushButtonDone::paintEvent(QPaintEvent *)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
if("Cancel" == text_)
{
QFont font = p.font();
font.setPointSize(24);
p.setFont(font);
}
p.drawText(QPoint(9, 65), text_);
}
示例3: paintEvent
void ComboTabBar::paintEvent(QPaintEvent* ev)
{
Q_UNUSED(ev);
// This is needed to apply style sheets
QStyleOption option;
option.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &option, &p, this);
#ifndef Q_OS_MAC
// Draw tabbar base even on parts of ComboTabBar that are not directly QTabBar
QStyleOptionTabBarBaseV2 opt;
TabBarHelper::initStyleBaseOption(&opt, m_mainTabBar, size());
// Left container
opt.rect.setX(m_leftContainer->x());
opt.rect.setWidth(m_leftContainer->width());
style()->drawPrimitive(QStyle::PE_FrameTabBarBase, &opt, &p);
// Right container
opt.rect.setX(m_rightContainer->x());
opt.rect.setWidth(m_rightContainer->width());
style()->drawPrimitive(QStyle::PE_FrameTabBarBase, &opt, &p);
if (m_mainBarOverFlowed) {
const int scrollButtonWidth = m_mainTabBarWidget->scrollButtonsWidth();
// Left scroll button
opt.rect.setX(m_mainTabBarWidget->x());
opt.rect.setWidth(scrollButtonWidth);
style()->drawPrimitive(QStyle::PE_FrameTabBarBase, &opt, &p);
// Right scroll button
opt.rect.setX(m_mainTabBarWidget->x() + m_mainTabBarWidget->width() - scrollButtonWidth);
opt.rect.setWidth(scrollButtonWidth);
style()->drawPrimitive(QStyle::PE_FrameTabBarBase, &opt, &p);
}
// Draw base even when main tabbar is empty
if (normalTabsCount() == 0) {
opt.rect.setX(m_mainTabBarWidget->x());
opt.rect.setWidth(m_mainTabBarWidget->width());
style()->drawPrimitive(QStyle::PE_FrameTabBarBase, &opt, &p);
}
#endif
}
示例4: paintEvent
void LaunchyWidget::paintEvent(QPaintEvent* event)
{
// Do the default draw first to render any background specified in the stylesheet
QStyleOption styleOption;
styleOption.init(this);
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
style()->drawPrimitive(QStyle::PE_Widget, &styleOption, &painter, this);
// Now draw the standard frame.png graphic if there is one
if (frameGraphic)
{
painter.drawPixmap(0,0, *frameGraphic);
}
QWidget::paintEvent(event);
}
示例5: file
void view::visualizer::callGraph::paintEvent(QPaintEvent *)
{
QString filename = QString(((binspector *)thisParent)->getActiveAnalysisPath() + "/graphs/callGraph.png");
QFile file(filename);
if (file.exists())
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
QPixmap graph(filename);
p.drawPixmap(0, 0, graph.scaled(size()));
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
}
示例6: buttonShift
static QSize buttonShift(const QwtLegendItem *w)
{
#if QT_VERSION < 0x040000
const int ph = w->style().pixelMetric(
QStyle::PM_ButtonShiftHorizontal, w);
const int pv = w->style().pixelMetric(
QStyle::PM_ButtonShiftVertical, w);
#else
QStyleOption option;
option.init(w);
const int ph = w->style()->pixelMetric(
QStyle::PM_ButtonShiftHorizontal, &option, w);
const int pv = w->style()->pixelMetric(
QStyle::PM_ButtonShiftVertical, &option, w);
#endif
return QSize(ph, pv);
}
示例7: paintEvent
/*!
\brief Qt Paint Event
\param event Paint event
*/
void QwtWheel::paintEvent( QPaintEvent *event )
{
QPainter painter( this );
painter.setClipRegion( event->region() );
QStyleOption opt;
opt.init(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
qDrawShadePanel( &painter,
contentsRect(), palette(), true, d_data->borderWidth );
drawWheelBackground( &painter, wheelRect() );
drawTicks( &painter, wheelRect() );
if ( hasFocus() )
QwtPainter::drawFocusRect( &painter, this );
}
示例8: setOrientation
//-----------------------------------------------------------------------------
void ctkExpandButton::setOrientation(Qt::Orientation newOrientation)
{
Q_D(ctkExpandButton);
QStyleOption opt;
opt.init(this);
if(newOrientation == Qt::Horizontal)
{
d->defaultPixmap = this->style()->standardPixmap(
QStyle::SP_ToolBarHorizontalExtensionButton, &opt);
d->orientation = Qt::Horizontal;
}
else
{
d->defaultPixmap = this->style()->standardPixmap(
QStyle::SP_ToolBarVerticalExtensionButton, &opt);
d->orientation = Qt::Vertical;
}
this->updateIcon(d->direction);
}
示例9: paintEvent
/*!
Qt paint event handler
\param event Paint event
*/
void QwtSlider::paintEvent( QPaintEvent *event )
{
QPainter painter( this );
painter.setClipRegion( event->region() );
QStyleOption opt;
opt.init(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
if ( d_data->scalePosition != QwtSlider::NoScale )
{
if ( !d_data->sliderRect.contains( event->rect() ) )
scaleDraw()->draw( &painter, palette() );
}
drawSlider( &painter, d_data->sliderRect );
if ( hasFocus() )
QwtPainter::drawFocusRect( &painter, this, d_data->sliderRect );
}
示例10: minimumSizeHint
/*!
\brief Return a minimum size hint
*/
QSize QwtArrowButton::minimumSizeHint() const
{
const QSize asz = arrowSize( Qt::RightArrow, QSize() );
QSize sz(
2 * Margin + ( MaxNum - 1 ) * Spacing + MaxNum * asz.width(),
2 * Margin + asz.height()
);
if ( d_data->arrowType == Qt::UpArrow || d_data->arrowType == Qt::DownArrow )
sz.transpose();
QStyleOption styleOption;
styleOption.init( this );
sz = style()->sizeFromContents( QStyle::CT_PushButton,
&styleOption, sz, this );
return sz;
}
示例11: paintEvent
void GroupButton::paintEvent(QPaintEvent *) {
QStyleOption opt;
opt.init(this);
QPainter painter(this);
QPen pen(Qt::white, 5);
painter.setPen(pen);
QPainterPath path;
path.addRect(this->rect());
if (mButtonState == EGroupButtonState::clearAll) {
painter.fillPath(path, QBrush(computeHighlightColor(mCheckedCount, mReachableCount)));
} else {
painter.fillPath(path, QBrush(QColor(32, 31, 31, 255)));
}
if (mIsSelected) {
painter.drawPath(path);
}
}
示例12: paintEvent
void CUiWidget_win::paintEvent(QPaintEvent *event)
{
QStyleOption opt;
QPainter p(this);
QRect r;
//QPainterPath path;
//QRegion region;
//int xroundness = 1, yroundness = 2;
r = rect();
opt.init(this);
/*
// isMaximized doesn't work here, because we change
// the maximize logic, we can use the new 'widgetState' method
if (isFullScreen() || widgetState() == Qt::WindowMaximized )
{
setMask(region);
}
else
{
path.addRoundRect(0, 0, r.width(), r.height(), xroundness, yroundness);
p.setClipPath(path);
region = p.clipRegion();
setMask(region);
}
*/
QPalette defaultPalette = QApplication::palette(this);
/*
QColor c;
QPixmap pixmap(":/res/icons/woodbackground.png");
for (int i = 0; i < QPalette::NColorGroups; ++i)
{
c = defaultPalette.brush(QPalette::ColorGroup(i), QPalette::Window).color();
defaultPalette.setBrush(QPalette::ColorGroup(i), QPalette::Window, pixmap);
}
*/
setPalette(defaultPalette);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
示例13: paintEvent
void MasterSlider::paintEvent(QPaintEvent *event)
{
QPainter p(this);
p.setPen(Qt::black);
p.rotate(180);
p.setRenderHint(QPainter::Antialiasing);
QStyleOption opt;
opt.init(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QColor myPenColor = QColor(0,0,0,255);
QBrush *brush = new QBrush(myPenColor,Qt::SolidPattern);
p.setPen(myPenColor);
p.setBrush(*brush);
unsigned short * levels = controllerm->getLevels(1);
y = -300;
int g = 0;
for(int i = 0;i < numOuts;i++)
{
if(i == 4)
{
g = 0;
y = -600;
}
x = -40 * (g + 1);
unsigned short lax = levels[i];
volRect = new QRect(x,y,30,lax/200);
p.drawRect(*volRect);
p.rotate(180);
QString text = "";
QString text2 = QString::number(i + 1);
p.drawText(-x - 25,-y + 100, text.append(text2));
p.rotate(180);
g++;
}
p.rotate(180);
}
示例14: paintEvent
void LiveChatMembersControl::paintEvent(QPaintEvent* _e)
{
QStyleOption opt;
opt.init(this);
QPainter painter(this);
painter.setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform|QPainter::TextAntialiasing);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
int maxCount = (geometry().width() - sv(avatarWithFrameHeight)) / (sv(avatarWithFrameHeight) - sv(avatarIntersection) - sv(frameWidth)) + 1;
int xOffset = 0;
for (const auto& chat : members_)
{
if (maxCount <= 0)
break;
painter.setBrush(Qt::white);
painter.setPen(Qt::white);
painter.drawEllipse(xOffset, 0, sv(avatarWithFrameHeight), sv(avatarWithFrameHeight));
bool isDefault = false;
const auto &avatar = Logic::GetAvatarStorage()->GetRounded(chat.first, chat.second, Utils::scale_bitmap(sv(avatarHeight)), QString(), true, isDefault);
if (!avatar->isNull())
{
painter.drawPixmap(xOffset + sv(frameWidth), sv(frameWidth), sv(avatarHeight), sv(avatarHeight), *avatar);
}
xOffset += sv(avatarWithFrameHeight) - sv(avatarIntersection) - sv(frameWidth);
--maxCount;
}
return QWidget::paintEvent(_e);
}
示例15: paintEvent
void ListMoodPreviewWidget::paintEvent(QPaintEvent *) {
QStyleOption opt;
opt.init(this);
QPainter painter(this);
QPen pen(Qt::white, 5);
painter.setPen(pen);
QPainterPath path;
path.addRect(this->rect());
painter.setRenderHint(QPainter::Antialiasing);
if (mIsChecked) {
painter.fillRect(this->rect(), QBrush(QColor(61, 142, 201)));
} else {
painter.fillRect(this->rect(), QBrush(QColor(32, 31, 31)));
}
if (mIsSelected) {
painter.drawPath(path);
}
}