CopperSpice API
1.9.2
|
Stores the parameters used by methods in QStyle. More...
Public Types | |
enum | OptionType |
enum | StyleOptionType |
enum | StyleOptionVersion |
Public Methods | |
QStyleOption (const QStyleOption &other) | |
QStyleOption (int version=QStyleOption::Version, int type=SO_Default) | |
~QStyleOption () | |
void | initFrom (const QWidget *widget) |
QStyleOption & | operator= (const QStyleOption &other) |
Public Members | |
int | type |
int | version |
Related Functions | |
These are not member functions | |
T | qstyleoption_cast (const QStyleOption *option) |
T | qstyleoption_cast (QStyleOption *option) |
The QStyleOption class stores the parameters used by methods in the QStyle class. This class and its subclasses contain all the information QStyle needs to draw a graphical element. For performance reasons there are few methods and the data is stored in public data members.
The following code shows how to use a QStyleOptionButton to paint a push button. The control is a QStyle::CE_PushButton and the QStyle::drawControl() uses a QStyleOptionButton.
When reimplementing QStyle methods which use a QStyleOption parameter, you may need to cast the QStyleOption to the child data type. The qstyleoption_cast() will return a nullptr if the object is not of the correct type.
This enum is used internally by QStyleOption and its subclasses
Constant | Value | Description |
---|---|---|
QStyleOption::SO_Button | 2 | QStyleOptionButton |
QStyleOption::SO_ComboBox | ? | QStyleOptionComboBox |
QStyleOption::SO_Complex | 0xf0000 | QStyleOptionComplex |
QStyleOption::SO_Default | 0 | QStyleOption |
QStyleOption::SO_DockWidget | 9 | QStyleOptionDockWidget |
QStyleOption::SO_FocusRect | 1 | QStyleOptionFocusRect |
QStyleOption::SO_Frame | 5 | QStyleOptionFrame |
QStyleOption::SO_GraphicsItem | 15 | QStyleOptionGraphicsItem |
QStyleOption::SO_GroupBox | ? | QStyleOptionGroupBox |
QStyleOption::SO_Header | 8 | QStyleOptionHeader |
QStyleOption::SO_MenuItem | 4 | QStyleOptionMenuItem |
QStyleOption::SO_ProgressBar | 6 | QStyleOptionProgressBar |
QStyleOption::SO_RubberBand | 13 | QStyleOptionRubberBand |
QStyleOption::SO_SizeGrip | ? | QStyleOptionSizeGrip |
QStyleOption::SO_Slider | ? | QStyleOptionSlider |
QStyleOption::SO_SpinBox | ? | QStyleOptionSpinBox |
QStyleOption::SO_Tab | 3 | QStyleOptionTab |
QStyleOption::SO_TabBarBase | 12 | QStyleOptionTabBarBase |
QStyleOption::SO_TabWidgetFrame | 11 | QStyleOptionTabWidgetFrame |
QStyleOption::SO_TitleBar | ? | QStyleOptionTitleBar |
QStyleOption::SO_ToolBar | 14 | QStyleOptionToolBar |
QStyleOption::SO_ToolBox | 7 | QStyleOptionToolBox |
QStyleOption::SO_ToolButton | ? | QStyleOptionToolButton |
QStyleOption::SO_ViewItem | 10 | QStyleOptionViewItem (used in Interviews) |
The following values are used for custom controls:
Constant | Value | Description |
---|---|---|
QStyleOption::SO_CustomBase | 0xf00 | Reserved for custom QStyleOptions; all custom controls values must be above this value |
QStyleOption::SO_ComplexCustomBase | 0xf000000 | Reserved for custom QStyleOptions; all custom complex controls values must be above this value |
This enum is used to hold information about the type of the style option and is defined for each QStyleOption subclass.
Constant | Value | Description |
---|---|---|
QStyleOption::Type | SO_Default | The type of style option provided by this class |
This enum is used to hold information about the version of the style option, and is defined for each QStyleOption subclass.
Constant | Value | Description |
---|---|---|
QStyleOption::Version | 1 | Version 1 |
QStyleOption::QStyleOption | ( | int | version = QStyleOption::Version , |
int | type = SO_Default |
||
) |
Constructs a QStyleOption with the specified version and type. The version has no special meaning for QStyleOption; it can be used by subclasses to distinguish between different version of the same option type.
The state member variable is initialized to QStyle::State_None.
QStyleOption::QStyleOption | ( | const QStyleOption & | other | ) |
Constructs a copy of other.
QStyleOption::~QStyleOption | ( | ) |
Destroys this style option object.
void QStyleOption::initFrom | ( | const QWidget * | widget | ) |
Initializes the state, direction, rect, palette, and fontMetrics member variables based on the specified widget.
QStyleOption & QStyleOption::operator= | ( | const QStyleOption & | other | ) |
Assign other to this QStyleOption.
|
related |
Returns a T or a default constructed T depending on the type and version of the given option.
|
related |
Returns a T or a default constructed T depending on the type of the given option.
QStyleOption::type |
This variable holds the type of the style option. The default value is SO_Default.
QStyleOption::version |
This variable holds the version of the style option. This value can be used by subclasses to implement extensions without breaking compatibility. If you use the qstyleoption_cast() function, you normally do not need to check it. The default value is 1.