📄 qstyleoption.cpp
字号:
version is used by QStyleOption subclasses to implement extensions without breaking compatibility. If you use qstyleoption_cast(), you normally don't need to check it. If you create your own QStyle subclass, you should handle both QStyleOptionProgressBar and QStyleOptionProgressBarV2. One way to achieve this is to use the QStyleOptionProgressBarV2 copy constructor. For example: \code if (const QStyleOptionProgressBar *progressBarOption = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) { QStyleOptionProgressBarV2 progressBarV2(*progressBarOption); // draw the progress bar using progressBarV2 } \endcode In the example above: If the \c progressBarOption's version is 1, the extra members (\l orientation, \l invertedAppearance, and \l bottomToTop) are set to default values for \c progressBarV2. If the \c progressBarOption's version is 2, the constructor will simply copy the extra members to progressBarV2. For an example demonstrating how style options can be used, see the \l {widgets/styles}{Styles} example. \sa QStyleOptionProgressBar, QStyleOption*//*! Constructs a QStyleOptionProgressBarV2. The members variables are initialized to default values.*/QStyleOptionProgressBarV2::QStyleOptionProgressBarV2() : QStyleOptionProgressBar(2), orientation(Qt::Horizontal), invertedAppearance(false), bottomToTop(false){}/*! \internal*/QStyleOptionProgressBarV2::QStyleOptionProgressBarV2(int version) : QStyleOptionProgressBar(version), orientation(Qt::Horizontal), invertedAppearance(false), bottomToTop(false){}/*! Constructs a copy of the \a other style option which can be either of the QStyleOptionProgressBar and QStyleOptionProgressBarV2 types. If the \a{other} style option's version is 1, the extra members (\l orientation, \l invertedAppearance, and \l bottomToTop) are set to default values for the new style option. If \a{other}'s version is 2, the extra members are simply copied. \sa version*/QStyleOptionProgressBarV2::QStyleOptionProgressBarV2(const QStyleOptionProgressBar &other) : QStyleOptionProgressBar(2), orientation(Qt::Horizontal), invertedAppearance(false), bottomToTop(false){ const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(&other); if (pb2) *this = *pb2; else *((QStyleOptionProgressBar *)this) = other;}/*! Constructs a copy of the \a other style option.*/QStyleOptionProgressBarV2::QStyleOptionProgressBarV2(const QStyleOptionProgressBarV2 &other) : QStyleOptionProgressBar(2), orientation(Qt::Horizontal), invertedAppearance(false), bottomToTop(false){ *this = other;}/*! Assigns the \a other style option to this style option. The \a other style option can be either of the QStyleOptionProgressBarV2 or QStyleOptionProgressBar types. If the \a{other} style option's version is 1, the extra members (\l orientation, \l invertedAppearance, and \l bottomToTop) are set to default values for this style option. If \a{other}'s version is 2, the extra members are simply copied to this style option.*/QStyleOptionProgressBarV2 &QStyleOptionProgressBarV2::operator=(const QStyleOptionProgressBar &other){ QStyleOptionProgressBar::operator=(other); const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(&other); orientation = pb2 ? pb2->orientation : Qt::Horizontal; invertedAppearance = pb2 ? pb2->invertedAppearance : false; bottomToTop = pb2 ? pb2->bottomToTop : false; return *this;}/*! \variable QStyleOptionProgressBarV2::orientation \brief the progress bar's orientation (horizontal or vertical) \sa QProgressBar::orientation*//*! \variable QStyleOptionProgressBarV2::invertedAppearance \brief whether the progress bar's appearance is inverted \sa QProgressBar::invertedAppearance*//*! \variable QStyleOptionProgressBarV2::bottomToTop \brief whether the text reads from bottom to top when the progress bar is vertical \sa QProgressBar::textDirection*//*! \class QStyleOptionMenuItem \brief The QStyleOptionMenuItem class is used to describe the parameter necessary for drawing a menu item. The QStyleOptionMenuItem is used for drawing menu items from \l QMenu. It is also used for drawing other menu-related widgets.*//*! Constructs a QStyleOptionMenuItem. The members variables are initialized to default values.*/QStyleOptionMenuItem::QStyleOptionMenuItem() : QStyleOption(QStyleOptionMenuItem::Version, SO_MenuItem), menuItemType(Normal), checkType(NotCheckable), checked(false), menuHasCheckableItems(true), maxIconWidth(0), tabWidth(0){}/*! \internal*/QStyleOptionMenuItem::QStyleOptionMenuItem(int version) : QStyleOption(version, SO_MenuItem), menuItemType(Normal), checkType(NotCheckable), checked(false), menuHasCheckableItems(true), maxIconWidth(0), tabWidth(0){}/*! \fn QStyleOptionMenuItem::QStyleOptionMenuItem(const QStyleOptionMenuItem &other) Constructs a copy of the \a other style option.*//*! \variable QStyleOptionMenuItem::Type Equals SO_MenuItem.*//*! \variable QStyleOptionMenuItem::Version Equals 1.*//*! \enum QStyleOptionMenuItem::MenuItemType These values indicate the type of menu item that the structure describes. \value Normal A normal menu item. \value DefaultItem A menu item that is the default action as specified with \l QMenu::defaultAction(). \value Separator A menu separator. \value SubMenu Indicates the menu item points to a sub-menu. \value Scroller A popup menu scroller (currently only used on Mac OS X). \value TearOff A tear-off handle for the menu. \value Margin The margin of the menu. \value EmptyArea The empty area of the menu.*//*! \enum QStyleOptionMenuItem::CheckType These enums are used to indicate whether or not a check mark should be drawn for the item, or even if it should be drawn at all. \value NotCheckable The item is not checkable. \value Exclusive The item is an exclusive check item (like a radio button). \value NonExclusive The item is a non-exclusive check item (like a check box). \sa QAction::checkable, QAction::checked, QActionGroup::exclusive*//*! \variable QStyleOptionMenuItem::menuItemType \brief the type of menu item \sa MenuItemType*//*! \variable QStyleOptionMenuItem::checkType \brief The type of checkmark of the menu item \sa CheckType*//*! \variable QStyleOptionMenuItem::checked \brief whether the menu item is checked or not.*//*! \variable QStyleOptionMenuItem::menuHasCheckableItems \brief whether the menu as a whole has checkable items or not. If this option is set to false, then the menu has no checkable items. This makes it possible for GUI styles to save some horizontal space that would normally be used for the check column.*//*! \variable QStyleOptionMenuItem::menuRect \brief The rectangle for the entire menu.*//*! \variable QStyleOptionMenuItem::text \brief The text for the menu item. Note that the text format is something like this "Menu text\bold{\\t}Shortcut". If the menu item doesn't have a shortcut, it will just contain the menu item's text.*//*! \variable QStyleOptionMenuItem::icon \brief The icon for the menu item.*//*! \variable QStyleOptionMenuItem::maxIconWidth \brief the maximum icon width for the icon in the menu item. This can be used for drawing the icon into the correct place or properly aligning items. The variable must be set regardless of whether or not the menu item has an icon.*//*! \variable QStyleOptionMenuItem::tabWidth \brief The tab width for the menu item. The tab width is the distance between the text of the menu item and the shortcut.*//*! \variable QStyleOptionMenuItem::font \brief The font used for the menu item text. This is the font that should be used for drawing the menu text minus the shortcut. The shortcut is usually drawn using the painter's font.*//*! \class QStyleOptionComplex \brief The QStyleOptionComplex class is used to hold parameters that are common to all complex controls. This class is not used on its own. Instead it is used to derive other complex control options, for example \l QStyleOptionSlider and \l QStyleOptionSpinBox.*//*! Constructs a QStyleOptionComplex of type \a type and version \a version. Usually this constructor is called by subclasses. The \l subControls member is initialized to \l QStyle::SC_All. The \l activeSubControls member is initialized to \l QStyle::SC_None.*/QStyleOptionComplex::QStyleOptionComplex(int version, int type) : QStyleOption(version, type), subControls(QStyle::SC_All), activeSubControls(QStyle::SC_None){}/*! \fn QStyleOptionComplex::QStyleOptionComplex(const QStyleOptionComplex &other) Constructs a copy of the \a other style option.*//*! \variable QStyleOptionComplex::Type Equals SO_Complex.*//*! \variable QStyleOptionComplex::Version Equals 1.*//*! \variable QStyleOptionComplex::subControls \brief The sub-controls that need to be painted. This is a bitwise OR of the various sub-controls that need to be drawn for the complex control. \sa QStyle::SubControl*//*! \variable QStyleOptionComplex::activeSubControls \brief The sub-controls that are active for the complex control. This a bitwise OR of the various sub-controls that are active (pressed) for the complex control. \sa QStyle::SubControl*/#ifndef QT_NO_SLIDER/*! \class QStyleOptionSlider \brief The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider. The QStyleOptionSlider class is used for drawing \l QSlider and \l QScrollBar.*//*! Constructs a QStyleOptionSlider. The members variables are initialized to default values.*/QStyleOptionSlider::QStyleOptionSlider() : QStyleOptionComplex(Version, SO_Slider), orientation(Qt::Horizontal), minimum(0), maximum(0), tickPosition(QSlider::NoTicks), tickInterval(0), upsideDown(false), sliderPosition(0), sliderValue(0), singleStep(0), pageStep(0), notchTarget(0.0), dialWrapping(false){}/*! \internal*/QStyleOptionSlider::QStyleOptionSlider(int version) : QStyleOptionComplex(version, SO_Slider), orientation(Qt::Horizontal), minimum(0), maximum(0), tickPosition(QSlider::NoTicks), tickInterval(0), upsideDown(false), sliderPosition(0), sliderValue(0), singleStep(0), pageStep(0), notchTarget(0.0), dialWrapping(false){}/*! \fn QStyleOptionSlider::QStyleOptionSlider(const QStyleOptionSlider &other) Constructs a copy of the \a other style option.*//*! \variable QStyleOptionSlider::Type Equals SO_Slider.*//*! \variable QStyleOptionSlider::Version Equals 1.*//*! \variable QStyleOptionSlider::orientation \brief the slider's orientation (horizontal or vertical) \sa Qt::Orientation*//*! \variable QStyleOptionSlider::minimum \brief The minimum value for the slider.*//*! \variable QStyleOptionSlider::maximum \brief The maximum value for the slider.*//*! \variable QStyleOptionSlider::tickPosition \brief the position of the slider's tick marks, if any. \sa QSlider::TickPosition*//*! \variable QStyleOptionSlider::tickInterval \brief The interval that should be drawn between tick marks.*//*! \variable QStyleOptionSlider::notchTarget \brief The number of pixel between notches \sa QDial::notchTarget()*//*! \variable QStyleOptionSlider::dialWrapping \brief Indicates whether or not the dial should wrap or not \sa QDial::wrapping()*//*! \variable QStyleOptionSlider::upsideDown \brief Indicates slider control orientation. Normally a slider increases as it moves up or to the right; upsideDown indicates that it should do the opposite (increase as it moves down or to the left). \sa QStyle::sliderPositionFromValue(), QStyle::sliderValueFromPosition(), QAbstractSlider::invertedAppearance*//*! \variable QStyleOptionSlider::sliderPosition \brief The position of the slider handle. If the slider has active feedback (i.e., QAbstractSlider::tracking is true), this value will be the same as \l sliderValue. Otherwise, it will have the current position of the handle. \sa QAbstractSlider::tracking, sliderValue*//*! \variable QStyleOptionSlider::sliderValue \brief The value of the slider. If the slider has active feedback (i.e., QAbstractSlider::tracking is true), this value will be the same as \l sliderPosition. Otherwise, it will have the value the slider had before the mouse was pressed. \sa QAbstractSlider::tracking sliderPosition*//*! \variable QStyleOptionSlider::singleStep \brief The size of the single step of the slider. \sa QAbstractSlider::singleStep*//*! \variable QStyleOptionSlider::pageStep \brief The size of the page step of the slider. \sa QAbstractSlider::pageStep
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -