本文整理汇总了C++中QStyle::subControlRect方法的典型用法代码示例。如果您正苦于以下问题:C++ QStyle::subControlRect方法的具体用法?C++ QStyle::subControlRect怎么用?C++ QStyle::subControlRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStyle
的用法示例。
在下文中一共展示了QStyle::subControlRect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: spinBoxEditFieldRect
/******************************************************************************
* Calculate the width and position of the extra pair of spin buttons.
* Style-specific adjustments are made for a better appearance.
*/
void SpinBox2::getMetrics() const
{
QStyleOptionSpinBox option;
mUpdown2->initStyleOption(option);
QStyle* udStyle = mUpdown2->style();
QRect butRect = udStyle->subControlRect(QStyle::CC_SpinBox, &option, QStyle::SC_SpinBoxUp)
| udStyle->subControlRect(QStyle::CC_SpinBox, &option, QStyle::SC_SpinBoxDown);
if (style()->inherits("PlastikStyle"))
butRect.setLeft(butRect.left() - 1); // Plastik excludes left border from spin widget rectangle
QRect r = spinBoxEditFieldRect(mSpinbox, option);
wSpinboxHide = mRightToLeft ? mSpinbox->style()->subControlRect(QStyle::CC_SpinBox, &option, QStyle::SC_SpinBoxFrame).right() - r.right() : r.left();
QRect edRect = spinBoxEditFieldRect(mUpdown2, option);
int butx;
if (isMirrorStyle(udStyle))
{
if (mRightToLeft)
{
wUpdown2 = edRect.left();
butx = butRect.left();
}
else
{
int x = edRect.right() + 1;
wUpdown2 = mUpdown2->width() - x;
butx = butRect.left() - x;
}
}
else
{
r = udStyle->subControlRect(QStyle::CC_SpinBox, &option, QStyle::SC_SpinBoxFrame);
if (mRightToLeft)
{
wUpdown2 = edRect.left() - r.left();
butx = wUpdown2 - (butRect.left() - r.left() + butRect.width());
}
else
{
wUpdown2 = r.width() - edRect.right() - 1;
butx = r.right() - butRect.right();
}
}
mButtonPos = QPoint(butx, butRect.top());
// qCDebug(KALARM_LOG) << "wUpdown2="<<wUpdown2<<", wSpinboxHide="<<wSpinboxHide<<", frame right="<<r.right() - butRect.right();
}
示例2: setButtons
void SpinMirror::setButtons()
{
mSpinbox->inhibitPaintSignal(2);
QStyleOptionSpinBox option;
mSpinbox->initStyleOption(option);
QStyle* st = mSpinbox->style();
QRect r = st->subControlRect(QStyle::CC_SpinBox, &option, QStyle::SC_SpinBoxUp)
| st->subControlRect(QStyle::CC_SpinBox, &option, QStyle::SC_SpinBoxDown);
if (isOxygenStyle(mSpinbox))
{
// They don't use all their height, so shorten them to
// allow frame highlighting to work properly.
r.setTop(r.top() + 1);
r.setHeight(r.height() - 2);
}
mSpinbox->inhibitPaintSignal(1);
mButtons->setPixmap(grabWidget(mSpinbox, r));
mSpinbox->inhibitPaintSignal(0);
}
示例3: region
QRegion QDecorationStyled::region(const QWidget *widget, const QRect &rect, int decorationRegion)
{
QStyle *style = QApplication::style();
// In the case of a borderless title bar, the title bar must be expanded one
// borderWidth to the left, right and up.
bool noTitleBorder = style->styleHint(QStyle::SH_TitleBar_NoBorder, 0, widget);
int borderWidth = style->pixelMetric(QStyle::PM_MDIFrameWidth, 0, 0);
int titleHeight = titleBarHeight(widget) + (noTitleBorder ? borderWidth : 0);
int titleExtra = noTitleBorder ? borderWidth : 0;
QRect inside = QRect(rect.x() - titleExtra, rect.top() - titleHeight,
rect.width() + 2 * titleExtra, titleHeight);
Qt::WindowFlags flags = widget->windowFlags();
bool hasSysMenu = flags & Qt::WindowSystemMenuHint;
bool hasContextHelp = flags & Qt::WindowContextHelpButtonHint;
bool hasMinimize = flags & Qt::WindowMinimizeButtonHint;
bool hasMaximize = flags & Qt::WindowMaximizeButtonHint;
QStyleOptionTitleBar opt;
opt.subControls = QStyle::SC_TitleBarLabel
| QStyle::SC_TitleBarSysMenu
| QStyle::SC_TitleBarNormalButton
| QStyle::SC_TitleBarMinButton
| QStyle::SC_TitleBarMaxButton
| QStyle::SC_TitleBarCloseButton;
opt.titleBarFlags = widget->windowFlags();
opt.direction = QApplication::layoutDirection();
opt.text = windowTitleFor(widget);
opt.icon = widget->windowIcon();
opt.rect = inside;
QRegion region;
switch (decorationRegion) {
case Title:
region = style->subControlRect(QStyle::CC_TitleBar, &opt,
QStyle::SC_TitleBarLabel, 0);
break;
case Menu:
if (hasSysMenu)
region = style->subControlRect(QStyle::CC_TitleBar, &opt,
QStyle::SC_TitleBarSysMenu, 0);
break;
case Help:
if (hasContextHelp)
region = style->subControlRect(QStyle::CC_TitleBar, &opt,
QStyle::SC_TitleBarContextHelpButton,
0);
break;
case Normalize:
if (hasMaximize | hasMinimize)
region = style->subControlRect(QStyle::CC_TitleBar, &opt,
QStyle::SC_TitleBarNormalButton,
0);
break;
case Minimize:
if (hasMinimize)
region = style->subControlRect(QStyle::CC_TitleBar, &opt,
QStyle::SC_TitleBarMinButton,
0);
break;
case Maximize:
if (hasMaximize)
region = style->subControlRect(QStyle::CC_TitleBar, &opt,
QStyle::SC_TitleBarMaxButton,
0);
break;
case Close:
region = style->subControlRect(QStyle::CC_TitleBar, &opt,
QStyle::SC_TitleBarCloseButton, 0);
break;
default:
region = QDecorationDefault::region(widget, rect, decorationRegion);
}
opt.rect = QRect(rect.x() - titleExtra, rect.top() - titleHeight,
rect.width() + 2 * titleExtra,
rect.height() + titleHeight + titleExtra);
QStyleHintReturnMask mask;
style->styleHint(QStyle::SH_WindowFrame_Mask, &opt, 0, &mask);
return (mask.region.isEmpty() ? region : (region & mask.region));
}
示例4: switch
NS_IMETHODIMP
nsNativeThemeQt::GetMinimumWidgetSize(nsRenderingContext* aContext, nsIFrame* aFrame,
PRUint8 aWidgetType,
nsIntSize* aResult, bool* aIsOverridable)
{
(*aResult).width = (*aResult).height = 0;
*aIsOverridable = PR_TRUE;
QStyle *s = qApp->style();
PRInt32 p2a = aContext->AppUnitsPerDevPixel();
switch (aWidgetType) {
case NS_THEME_RADIO:
case NS_THEME_CHECKBOX: {
nsRect frameRect = aFrame->GetRect();
QRect qRect = qRectInPixels(frameRect, p2a);
QStyleOptionButton option;
InitButtonStyle(aWidgetType, aFrame, qRect, option);
QRect rect = s->subElementRect(
(aWidgetType == NS_THEME_CHECKBOX) ?
QStyle::SE_CheckBoxIndicator :
QStyle::SE_RadioButtonIndicator,
&option,
NULL);
(*aResult).width = rect.width();
(*aResult).height = rect.height();
break;
}
case NS_THEME_BUTTON: {
nsRect frameRect = aFrame->GetRect();
QRect qRect = qRectInPixels(frameRect, p2a);
QStyleOptionButton option;
InitButtonStyle(aWidgetType, aFrame, qRect, option);
QRect rect = s->subElementRect(
QStyle::SE_PushButtonFocusRect,
&option,
NULL);
(*aResult).width = rect.width();
(*aResult).height = rect.height();
break;
}
case NS_THEME_SCROLLBAR_BUTTON_UP:
case NS_THEME_SCROLLBAR_BUTTON_DOWN: {
(*aResult).width = s->pixelMetric(QStyle::PM_ScrollBarExtent);
(*aResult).height = (*aResult).width;
//*aIsOverridable = PR_FALSE;
break;
}
case NS_THEME_SCROLLBAR_BUTTON_LEFT:
case NS_THEME_SCROLLBAR_BUTTON_RIGHT: {
(*aResult).height = s->pixelMetric(QStyle::PM_ScrollBarExtent);
(*aResult).width = (*aResult).height;
//*aIsOverridable = PR_FALSE;
break;
}
case NS_THEME_SCROLLBAR_THUMB_VERTICAL: {
(*aResult).width = s->pixelMetric(QStyle::PM_ScrollBarExtent);
(*aResult).height = s->pixelMetric(QStyle::PM_ScrollBarSliderMin);
//*aIsOverridable = PR_FALSE;
break;
}
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL: {
(*aResult).width = s->pixelMetric(QStyle::PM_ScrollBarSliderMin);
(*aResult).height = s->pixelMetric(QStyle::PM_ScrollBarExtent);
//*aIsOverridable = PR_FALSE;
break;
}
case NS_THEME_SCROLLBAR_TRACK_VERTICAL: {
(*aResult).width = s->pixelMetric(QStyle::PM_ScrollBarExtent);
(*aResult).height = s->pixelMetric(QStyle::PM_SliderLength);
break;
}
case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL: {
(*aResult).width = s->pixelMetric(QStyle::PM_SliderLength);
(*aResult).height = s->pixelMetric(QStyle::PM_ScrollBarExtent);
break;
}
case NS_THEME_DROPDOWN_BUTTON: {
QStyleOptionComboBox comboOpt;
nsRect frameRect = aFrame->GetRect();
QRect qRect = qRectInPixels(frameRect, p2a);
comboOpt.rect = qRect;
InitComboStyle(aWidgetType, aFrame, qRect, comboOpt);
QRect subRect = s->subControlRect(QStyle::CC_ComboBox, &comboOpt, QStyle::SC_ComboBoxArrow, NULL);
(*aResult).width = subRect.width();
//.........这里部分代码省略.........