📄 qstyleoption.cpp
字号:
*//*! Constructs a QStyleOptionTabV2 copy of the \a other style option which can be either of the QStyleOptionTabV2 or QStyleOptionTab types. If the other style option's version is 1, the new style option's \c iconSize is set to an invalid value. If its version is 2, its \c iconSize value is simply copied to the new style option.*/QStyleOptionTabV2::QStyleOptionTabV2(const QStyleOptionTab &other) : QStyleOptionTab(Version){ if (const QStyleOptionTabV2 *tab = qstyleoption_cast<const QStyleOptionTabV2 *>(&other)) { *this = *tab; } else { *((QStyleOptionTab *)this) = other; version = Version; }}/*! Assigns the \a other style option to this QStyleOptionTabV2. The \a other style option can be either of the QStyleOptionTabV2 or QStyleOptionTab types. If the other style option's version is 1, this style option's \c iconSize is set to an invalid size. If its version is 2, its \c iconSize value is simply copied to this style option.*/QStyleOptionTabV2 &QStyleOptionTabV2::operator=(const QStyleOptionTab &other){ QStyleOptionTab::operator=(other); if (const QStyleOptionTabV2 *tab = qstyleoption_cast<const QStyleOptionTabV2 *>(&other)) iconSize = tab->iconSize; else iconSize = QSize(); return *this;}#endif // QT_NO_TABBAR/*! \class QStyleOptionProgressBar \brief The QStyleOptionProgressBar class is used to describe the parameters necessary for drawing a progress bar. Since Qt 4.1, Qt uses the QStyleOptionProgressBarV2 subclass for drawing QProgressBar. An instance of the QStyleOptionProgressBar class has type SO_ProgressBar and version 1. The type is used internally by QStyleOption, its subclasses, and qstyleoption_cast() to determine the type of style option. In general you do not need to worry about this unless you want to create your own QStyleOption subclass and your own styles. The 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. For an example demonstrating how style options can be used, see the \l {widgets/styles}{Styles} example. \sa QStyleOptionProgressBarV2, QStyleOption*//*! Constructs a QStyleOptionProgressBar, initializing the members variables to their default values.*/QStyleOptionProgressBar::QStyleOptionProgressBar() : QStyleOption(QStyleOptionProgressBar::Version, SO_ProgressBar), minimum(0), maximum(0), progress(0), textAlignment(Qt::AlignLeft), textVisible(false){}/*! \internal*/QStyleOptionProgressBar::QStyleOptionProgressBar(int version) : QStyleOption(version, SO_ProgressBar), minimum(0), maximum(0), progress(0), textAlignment(Qt::AlignLeft), textVisible(false){}/*! \fn QStyleOptionProgressBar::QStyleOptionProgressBar(const QStyleOptionProgressBar &other) Constructs a copy of the \a other style option.*//*! \enum QStyleOptionProgressBar::StyleOptionType This enum is used to hold information about the type of the style option, and is defined for each QStyleOption subclass. \value Type The type of style option provided (\l{SO_ProgressBar} for this class). The type is used internally by QStyleOption, its subclasses, and qstyleoption_cast() to determine the type of style option. In general you do not need to worry about this unless you want to create your own QStyleOption subclass and your own styles. \sa StyleOptionVersion*//*! \enum QStyleOptionProgressBar::StyleOptionVersion This enum is used to hold information about the version of the style option, and is defined for each QStyleOption subclass. \value Version 1 The 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. \sa StyleOptionType*//*! \variable QStyleOptionProgressBar::minimum \brief the minimum value for the progress bar This is the minimum value in the progress bar. The default value is 0. \sa QProgressBar::minimum*//*! \variable QStyleOptionProgressBar::maximum \brief the maximum value for the progress bar This is the maximum value in the progress bar. The default value is 0. \sa QProgressBar::maximum*//*! \variable QStyleOptionProgressBar::text \brief the text for the progress bar The progress bar text is usually just the progress expressed as a string. An empty string indicates that the progress bar has not started yet. The default value is an empty string. \sa QProgressBar::text*//*! \variable QStyleOptionProgressBar::textVisible \brief a flag indicating whether or not text is visible If this flag is true then the text is visible. Otherwise, the text is not visible. The default value is false. \sa QProgressBar::textVisible*//*! \variable QStyleOptionProgressBar::textAlignment \brief the text alignment for the text in the QProgressBar This can be used as a guide on where the text should be in the progress bar. The default value is Qt::AlignLeft.*//*! \variable QStyleOptionProgressBar::progress \brief the current progress for the progress bar The current progress. A value of QStyleOptionProgressBar::minimum - 1 indicates that the progress hasn't started yet. The default value is 0. \sa QProgressBar::value*//*! \class QStyleOptionProgressBarV2 \brief The QStyleOptionProgressBarV2 class is used to describe the parameters necessary for drawing a progress bar in Qt 4.1 or above. \since 4.1 An instance of this class has \l type SO_ProgressBar and \l version 2. The type is used internally by QStyleOption, its subclasses, and qstyleoption_cast() to determine the type of style option. In general you do not need to worry about this unless you want to create your own QStyleOption subclass and your own styles. The 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: \quotefromfile snippets/qstyleoption/main.cpp \skipto MyStyle::MyStyle() \skipto *progressBarOption \printuntil } 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, initializing he members variables to their 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); the default orentation is Qt::Horizontal \sa QProgressBar::orientation*//*! \variable QStyleOptionProgressBarV2::invertedAppearance \brief whether the progress bar's appearance is inverted The default value is false. \sa QProgressBar::invertedAppearance*//*! \variable QStyleOptionProgressBarV2::bottomToTop \brief whether the text reads from bottom to top when the progress bar is vertical The default value is false. \sa QProgressBar::textDirection*//*! \enum QStyleOptionProgressBarV2::StyleOptionType This enum is used to hold information about the type of the style option, and is defined for each QStyleOption subclass. \value Type The type of style option provided (\l{SO_ProgressBar} for this class). The type is used internally by QStyleOption, its subclasses, and qstyleoption_cast() to determine the type of style option. In general you do not need to worry about this unless you want to create your own QStyleOption subclass and your own styles. \sa StyleOptionVersion*//*! \enum QStyleOptionProgressBarV2::StyleOptionVersion This enum is used to hold information about the version of the style option, and is defined for each QStyleOption subclass. \value Version 2 The 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. \sa StyleOptionType*//*! \class QStyleOptionMenuItem \brief The QStyleOptionMenuItem class is used to describe the parameter necessary for drawing a menu item. QStyleOptionMenuItem contains all the information that QStyle functions need to draw the menu items from \l QMenu. It is also used for drawing other menu-related widgets. For performance reasons, the access to the member variables is direct (i.e., using the \c . or \c -> operator). This low-level feel makes the structures straightforward to use and emphasizes that these are simply parameters used by the style functions. For an example demonstrating how style options can be used, see the \l {widgets/styles}{Styles} example. \sa QStyleOption*//*! Constructs a QStyleOptionMenuItem, initializing the members variables to their 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.*//*! \enum QStyleOptionMenuItem::StyleOptionType This enum is used to hold information about the type of the style option, and is defined for each QStyleOption subclass. \value Type The type of style option provided (\l{SO_MenuItem} for this class). The type is used internally by QStyleOption, its subclasses, and qstyleoption_cast() to determine the type of style option. In general you do not need to worry about this unless you want to create your own QStyleOption subclass and your own styles. \sa StyleOptionVersion*//*! \enum
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -