Here are some things to keep in mind when making a style work well in a right-to-left environment:. QStyleOption::direction indicates in which direction the item should be drawn in. The painting of items in views is performed by a delegate. See the QStyledItemDelegate class description to find out which datatypes and roles are supported.
When implementing a style to customize drawing of item views, you need to check the implementation of QCommonStyle and any other subclasses from which your style inherits. This way, you find out which and how other style elements are painted, and you can then reimplement the painting of elements that should be drawn differently.
To add support for drawing of new datatypes and item data roles, it is necessary to create a custom delegate. But if you only need to support the datatypes implemented by the default delegate, a custom style does not need an accompanying delegate.
The QStyledItemDelegate class description gives more information on custom delegates. The drawing of item view headers is also done by the style, giving control over size of header items and row and column sizes.
Note that not all primitives use all of these flags, and that the flags may mean different things to different items. This enum describes the various primitive elements. A primitive element is a common GUI element, such as a checkbox indicator or button bevel. Button used to initiate an action, for example, a QPushButton. Panel for a Tool button, used with QToolButton. Panel for a QLineEdit. Up symbol for a spin widget, for example a QSpinBox. Frame for an item of a status bar; see also QStatusBar.
Section of a progress bar indicator; see also QProgressBar. An indicator that a tab is partially scrolled out on the left side of the visible tab bar when there are many tabs.
An indicator that a tab is partially scrolled out on the right side of the visible tab bar when there are many tabs. An arrow in a QColumnView. A plain QWidget. Base value for custom primitive elements. All values above this are reserved for custom use. Custom values must be greater than this value. An indicator that is drawn to show where an item in an item view is about to be dropped during a drag-and-drop operation in an item view.
This enum represents a control element. A control element is a part of a widget that performs some action or displays information to the user. The bevel and default indicator of a QPushButton.
The label an icon with text or pixmap of a QPushButton. Splitter handle; see also QSplitter. The label text or pixmap of a QCheckBox. The label text or pixmap of a QRadioButton. The tab and label within a QTabBar.
A QProgressBar , draws , and. The groove where the progress indicator is drawn in a QProgressBar. The progress indicator of a QProgressBar. The text label of a QProgressBar. A menu item in a QMenuBar. The empty area of a QMenuBar. A menu item in a QMenu. Scrolling areas in a QMenu when the style supports scrolling. A menu item representing the tear off section of a QMenu. Window resize handle; see also QSizeGrip. Scroll bar line increase indicator.
The label of a non-editable QComboBox. A toolbar like QToolBar. This enum represents a sub-area of a widget. Style implementations use these areas to draw the different parts of a widget. This enum describes the available complex controls. Complex controls have different behavior depending upon where the user clicks on them or which keys are pressed.
A spinbox, like QSpinBox. A combobox, like QComboBox. A scroll bar, like QScrollBar. A slider, like QSlider. A tool button, like QToolButton. A group box, like QGroupBox. A dial, like QDial. SubControl drawComplexControl.
This enum describes the available sub controls. A subcontrol is a control element within a complex control ComplexControl. Scroll bar add line i. Combobox edit field; see also QComboBox. Tool button see also QToolButton. This enum describes the various available pixel metrics. A pixel metric is a style dependent size represented by a single pixel value.
Default left margin for a QLayout. Default top margin for a QLayout. Default right margin for a QLayout. Default bottom margin for a QLayout. Default horizontal spacing for a QLayout. Default vertical spacing for a QLayout. The maximum allowed distance between the mouse and a scrollbar when dragging. Exceeding the specified distance will cause the slider to jump back to the original position; a value of -1 disables this behavior. Width of a separator in a horizontal dock window and the height of a separator in a vertical dock window.
Width of the handle in a horizontal dock window and the height of the handle in a vertical dock window. Width of a toolbar handle in a horizontal toolbar and the height of the handle in a vertical toolbar. Width of a toolbar separator in a horizontal toolbar and the height of a separator in a vertical toolbar.
Width of a toolbar extension button in a horizontal toolbar and the height of the button in a vertical toolbar. Number of pixels the tabs should overlap. Currently only used in styles, not inside of QTabBar.
Border width applied on all sides for a QMenu. Additional border used on left and right for a QMenu. Additional border used for bottom and top for a QMenu. Height of the scroller area in a QMenu. Height of a tear off area in a QMenu. The default size of sections in a horizontal header. This enum value has been introduced in Qt 5. The default size of sections in a vertical header. This enum describes the available contents types. These are used to calculate sizes for the contents of various widgets.
A check box, like QCheckBox. A combo box, like QComboBox. A line edit, like QLineEdit. A menu, like QMenu. A menu bar, like QMenuBar. A menu bar item, like the buttons in a QMenuBar. A progress bar, like QProgressBar. A push button, like QPushButton. A radio button, like QRadioButton. A size grip, like QSizeGrip. A spin box, like QSpinBox. A splitter, like QSplitter. A tab on a tab bar, like QTabBar. A tab widget, like QTabWidget. This enum describes under what circumstances a software input panel will be requested by input capable widgets.
A boolean value. If true, middle clicking on a scroll bar causes the slider to jump to that position. If false, middle clicking is ignored.
If true, left clicking on a scroll bar causes the slider to jump to that position. If false, left clicking will behave as appropriate for each control. If true, when clicking a scroll bar SubControl , holding the mouse button down and moving the pointer outside the SubControl , the scroll bar continues to scroll.
If false, the scollbar stops scrolling when the pointer leaves the SubControl. When it is false, the original button is released and nothing happens like a push button. The alignment for tabs in a QTabWidget. The placement of the sorting indicator may appear in list or table headers.
Select the text in the line edit, or when selecting an item from the listbox, or when the line edit receives focus, as done on Windows. Whether popup menus must support the user moving the mouse cursor to a submenu while crossing other items of the menu. This is supported on most modern desktop platforms. Since Qt 5. If the cursor has to move towards the submenu like it is on macOS , or if the cursor can move in any direction as long as it reaches the submenu before the sloppy timeout.
Collectives on Stack Overflow. Learn more. Ask Question. Asked 11 years, 3 months ago. Active 11 years, 3 months ago. Viewed 6k times. Any ideas? Tryst Tryst 1 1 gold badge 6 6 silver badges 12 12 bronze badges. Add a comment. Active Oldest Votes. FramelessWindowHint whenever you see Qt. Returns the size of the element described by the specified option and type , based on the provided contentsSize.
QStyleOption or one of its subclasses. The widget is an optional argument and can contain extra information used for calculating the size. ContentsType PySide. Converts the given logicalValue to a pixel position.
The min parameter maps to 0, max maps to span and other values are distributed evenly in-between. This function can handle the entire integer range without overflow, providing that span is less than By default, this function assumes that the maximum value is on the right for horizontal items and on the bottom for vertical items.
Set the upsideDown parameter to true to reverse this behavior. Converts the given pixel position to a logical value. Returns an icon for the given standardIcon. The standardIcon is a standard pixmap which can follow some existing GUI style or guideline. The option argument can be used to pass extra information required when defining the appropriate icon.
The widget argument is optional and can also be used to aid the determination of the icon. Because of binary compatibility constraints, this function is not virtual.
If you want to provide your own icons in a PySide. QStyle subclass, reimplement the PySide. Reimplement this slot to provide your own icons in a PySide.
QStyle subclass; because of binary compatibility constraints, the PySide. Instead, PySide. In particular, the Windows XP, Vista, and Mac styles do not use the standard palette, but make use of native theme engines.
With these styles, you should not set the palette with QApplication::setStandardPalette. Returns a pixmap for the given standardPixmap. The option argument can be used to pass extra information required when defining the appropriate pixmap. The widget argument is optional and can also be used to aid the determination of the pixmap. Developers calling PySide.
Returns an integer representing the specified style hint for the given widget described by the provided style option. QStyleHintReturn class description for details. Returns the rectangle containing the specified subControl of the given complex control with the style specified by option. The rectangle is defined in screen coordinates. The option argument is a pointer to PySide.
The widget is optional and can contain additional information for the function. Returns the sub-area for the given element as described in the provided style option. The returned rectangle is defined in screen coordinates. The widget argument is optional and can be used to aid determining the area. This function is the counterpart to PySide. It is called for every polished widget whenever the style is dynamically changed; the former style has to unpolish its settings before the new style can polish them again.
Note that PySide. This can cause problems in some cases, e. PySide 1. It can also be specified by the user of the application, using the -style command-line option: python myapplication. QStyle draw functions take four arguments: an enum value specifying which graphical element to draw a PySide. QStyleOption specifying how and where to render that element a PySide. QPainter that should be used to draw the element a PySide.
Background style. Warning Qt style sheets are currently not supported for custom PySide. QApplication object: import sys from PySide. Here are some things to keep in mind when making a style work well in a right-to-left environment: PySide.
We include a small example where we customize the drawing of item backgrounds. See also PySide. See also QStyle. See also QEvent. Note This enum was introduced or modified in Qt 4. See also Qt.
Warning Because of binary compatibility constraints, this function is not virtual. Default left margin for a PySide. Default top margin for a PySide. Default right margin for a PySide.
Default bottom margin for a PySide. Default horizontal spacing for a PySide. Default vertical spacing for a PySide. The maximum allowed distance between the mouse and a scrollbar when dragging. Exceeding the specified distance will cause the slider to jump back to the original position; a value of -1 disables this behavior. Width of a separator in a horizontal dock window and the height of a separator in a vertical dock window. Width of the handle in a horizontal dock window and the height of the handle in a vertical dock window.
Width of a toolbar handle in a horizontal toolbar and the height of the handle in a vertical toolbar. Width of a toolbar separator in a horizontal toolbar and the height of a separator in a vertical toolbar. Width of a toolbar extension button in a horizontal toolbar and the height of the button in a vertical toolbar.
Number of pixels the tabs should overlap. Currently only used in styles, not inside of PySide. Border width applied on all sides for a PySide. Additional border used on left and right for a PySide. Additional border used for bottom and top for a PySide. Height of the scroller area in a PySide.
Height of a tear off area in a PySide. Scroll bar add line i. Combobox edit field; see also PySide. Tool button see also PySide. Sub-control for opening a popup menu in a tool button; see also Q3PopupMenu. Minimize button on title bars e. Close button on dock windows see also PySide. Icon for a standard OK button in a PySide. Icon for a standard Cancel button in a PySide.
Icon for a standard Help button in a PySide. Icon for a standard Open button in a PySide. Icon for a standard Save button in a PySide. Icon for a standard Close button in a PySide. Icon for a standard Apply button in a PySide. Icon for a standard Reset button in a PySide. Icon for a standard Discard button in a PySide. Icon for a standard Yes button in a PySide. Icon for a standard No button in a PySide.
This will return a null pixmap or icon on all other platforms. A boolean value. If true, middle clicking on a scroll bar causes the slider to jump to that position. If false, middle clicking is ignored. If true, left clicking on a scroll bar causes the slider to jump to that position.
If false, left clicking will behave as appropriate for each control. If true, when clicking a scroll bar QStyle. SubControl , holding the mouse button down and moving the pointer outside the QStyle. SubControl , the scroll bar continues to scroll. If false, the scollbar stops scrolling when the pointer leaves the QStyle.
When it is false, the original button is released and nothing happens like a push button. The alignment for tabs in a PySide.
Possible values are Qt. AlignLeft , Qt. AlignCenter and Qt. The placement of the sorting indicator may appear in list or table headers. Left or Qt. The alignment for text labels in progress dialogs; Qt. AlignCenter on Windows, Qt. AlignVCenter otherwise. Select the text in the line edit, or when selecting an item from the listbox, or when the line edit receives focus, as done on Windows.
Whether scrollviews draw their frame only around contents like Motif , or around contents, scroll bars and corner widgets like Windows. Menu bars items are navigable by pressing Alt, followed by using the arrow keys to select the desired item. Whether popups should allow the selections to wrap, that is when selection should the next item be the first item.
Boldness of the selected page title in a PySide. A QTextCharFormat. UnderlineStyle value that specifies the way misspelled words should be underlined. An integer indicating the opacity for the tip label, 0 is completely transparent, is completely opaque. A boolean indicating if a menu in the menu bar should be dismissed when it is clicked on a second time.
Example: Clicking and releasing on the File Menu in a menu bar and then immediately clicking on the File Menu again. A boolean indicating what the to use the border of the buttons computed as half the button height for the spacing of the button in a message box.
A boolean indicating whether the buttons in the message box should be centered or not see QDialogButtonBox::setCentered. A boolean indicating if the text in a message box should allow user interfactions e. A boolean indicating whether controls on a title bar ought to update when the mouse is over them. ColorRole for a dial widget. The layout direction for the combo box.
By default it should be the same as indicated by the QStyleOption. The location where ellipses should be added for item text that is too long to fit in an view item. Emit the activated signal when the user single clicks on an item in an item in an item view. Otherwise the signal is emitted when the user double clicks on an item.
Controls how buttons are laid out in a PySide. ButtonLayout enum. Controls the look and feel of a PySide. Returns a QWizard. WizardStyle enum. Provides a default for how rows are wrapped in a PySide.
0コメント