QStyleHints 類

QStyleHints 類包含平颱特定提示及設置。 更多...

頭: #include <QStyleHints>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
繼承: QObject

特性

公共函數

Qt::ColorScheme colorScheme () const
Qt::ContextMenuTrigger contextMenuTrigger () const
int cursorFlashTime () const
qreal fontSmoothingGamma () const
qreal keyboardAutoRepeatRateF () const
int keyboardInputInterval () const
int mouseDoubleClickDistance () const
int mouseDoubleClickInterval () const
int mousePressAndHoldInterval () const
int mouseQuickSelectionThreshold () const
QChar passwordMaskCharacter () const
int passwordMaskDelay () const
(從 6.8 起) void setColorScheme (Qt::ColorScheme scheme )
void setContextMenuTrigger (Qt::ContextMenuTrigger contextMenuTrigger )
bool setFocusOnTouchRelease () const
void setShowShortcutsInContextMenus (bool showShortcutsInContextMenus )
void setUseHoverEffects (bool useHoverEffects )
bool showIsFullScreen () const
bool showIsMaximized () const
bool showShortcutsInContextMenus () const
bool singleClickActivation () const
int startDragDistance () const
int startDragTime () const
int startDragVelocity () const
Qt::TabFocusBehavior tabFocusBehavior () const
int touchDoubleTapDistance () const
(從 6.8 起) void unsetColorScheme ()
bool useHoverEffects () const
bool useRtlExtensions () const
int wheelScrollLines () const

信號

void colorSchemeChanged (Qt::ColorScheme colorScheme )
void contextMenuTriggerChanged (Qt::ContextMenuTrigger contextMenuTrigger )
void cursorFlashTimeChanged (int cursorFlashTime )
void keyboardInputIntervalChanged (int keyboardInputInterval )
void mouseDoubleClickIntervalChanged (int mouseDoubleClickInterval )
void mousePressAndHoldIntervalChanged (int mousePressAndHoldInterval )
void mouseQuickSelectionThresholdChanged (int threshold )
void showShortcutsInContextMenusChanged (bool)
void startDragDistanceChanged (int startDragDistance )
void startDragTimeChanged (int startDragTime )
void tabFocusBehaviorChanged (Qt::TabFocusBehavior tabFocusBehavior )
void useHoverEffectsChanged (bool useHoverEffects )
void wheelScrollLinesChanged (int scrollLines )

詳細描述

此類的對象,獲取自 QGuiApplication ,提供對當前平颱某些全局用戶界麵參數的訪問。

Access to most settings is read only. The platform itself usually provides the user with ways to tune these parameters. Authors of custom user interface components should read relevant settings to allow the components to exhibit the same behavior and feel as other components.

另請參閱 QGuiApplication::styleHints ().

特性文檔編製

[since 6.5] colorScheme : Qt::ColorScheme

This property holds the color scheme used by the application.

By default, this follows the system's default color scheme (also known as appearance), and changes when the system color scheme changes (e.g. during dusk or dawn). Setting the color scheme to an explicit value will override the system setting and ignore any changes to the system's color scheme. However, doing so is a hint to the system, and overriding the color scheme is not supported on all platforms.

Resetting this property, or setting it to Qt::ColorScheme::Unknown , will remove the override and make the application follow the system default again. The property value will change to the color scheme the system currently has.

When this property changes, Qt will read the system palette and update the default palette, but won't overwrite palette entries that have been explicitly set by the application. When the colorSchemeChange() signal gets emitted, the old palette is still in effect.

Application-specific colors should be selected to work well with the effective palette, taking the current color scheme into account. To update application- specific colors when the effective palette changes, handle PaletteChange or ApplicationPaletteChange 事件。

該特性在 Qt 6.5 引入。

訪問函數:

Qt::ColorScheme colorScheme () const
void setColorScheme (Qt::ColorScheme scheme )
void unsetColorScheme ()

通知程序信號:

void colorSchemeChanged (Qt::ColorScheme colorScheme )

另請參閱 Qt::ColorScheme , QGuiApplication::palette (),和 QEvent::PaletteChange .

[since 6.8] contextMenuTrigger : Qt::ContextMenuTrigger

mouse event used to trigger a context menu event.

The default on UNIX systems is to show context menu on mouse button press event, while on Windows it is the mouse button release event. This property can be used to override the default platform behavior.

注意: Developers must use this property with great care, as it changes the default interaction mode that their users will expect on the platform that they are running on.

該特性在 Qt 6.8 引入。

訪問函數:

Qt::ContextMenuTrigger contextMenuTrigger () const
void setContextMenuTrigger (Qt::ContextMenuTrigger contextMenuTrigger )

通知程序信號:

void contextMenuTriggerChanged (Qt::ContextMenuTrigger contextMenuTrigger )

另請參閱 Qt::ContextMenuTrigger .

[read-only] cursorFlashTime : const int

This property holds the text cursor's flash (blink) time in milliseconds.

The flash time is the time used to display, invert and restore the caret display. Usually the text cursor is displayed for half the cursor flash time, then hidden for the same amount of time.

訪問函數:

int cursorFlashTime () const

通知程序信號:

void cursorFlashTimeChanged (int cursorFlashTime )

[read-only] fontSmoothingGamma : const qreal

This property holds the gamma value used in font smoothing.

訪問函數:

qreal fontSmoothingGamma () const

[read-only, since 6.5] keyboardAutoRepeatRateF : const qreal

This property holds the rate, in events per second, in which additional repeated key presses will automatically be generated if a key is being held down.

該特性在 Qt 6.5 引入。

訪問函數:

qreal keyboardAutoRepeatRateF () const

[read-only] keyboardInputInterval : const int

此特性保持區分鍵按下和 2 次連續按下的時間限製 (以毫秒為單位)。

訪問函數:

int keyboardInputInterval () const

通知程序信號:

void keyboardInputIntervalChanged (int keyboardInputInterval )

[read-only] mouseDoubleClickDistance : const int

This property holds the maximum distance, in pixels, that the mouse can be moved between two consecutive mouse clicks and still have it detected as a double-click

訪問函數:

int mouseDoubleClickDistance () const

[read-only] mouseDoubleClickInterval : const int

此特性保持區分雙擊和 2 次連續鼠標點擊的時間限製 (以毫秒為單位)。

訪問函數:

int mouseDoubleClickInterval () const

通知程序信號:

void mouseDoubleClickIntervalChanged (int mouseDoubleClickInterval )

[read-only] mousePressAndHoldInterval : const int

This property holds the time limit in milliseconds that activates a press and hold.

訪問函數:

int mousePressAndHoldInterval () const

通知程序信號:

void mousePressAndHoldIntervalChanged (int mousePressAndHoldInterval )

mouseQuickSelectionThreshold : const int

Quick selection mouse threshold in QLineEdit .

This property defines how much the mouse cursor should be moved along the y axis to trigger a quick selection during a normal QLineEdit text selection.

If the property value is less than or equal to 0, the quick selection feature is disabled.

訪問函數:

int mouseQuickSelectionThreshold () const

通知程序信號:

void mouseQuickSelectionThresholdChanged (int threshold )

[read-only] passwordMaskCharacter : const QChar

This property holds the character used to mask the characters typed into text input fields in password mode.

訪問函數:

QChar passwordMaskCharacter () const

[read-only] passwordMaskDelay : const int

This property holds the time, in milliseconds, a typed letter is displayed unshrouded in a text input field in password mode.

訪問函數:

int passwordMaskDelay () const

[read-only] setFocusOnTouchRelease : const bool

This property holds the event that should set input focus on focus objects.

此特性是 true if focus objects (line edits etc) should receive input focus after a touch/mouse release. This is normal behavior on touch platforms. On desktop platforms, the standard is to set focus already on touch/mouse press.

訪問函數:

bool setFocusOnTouchRelease () const

[read-only] showIsFullScreen : const bool

This property holds whether the platform defaults to fullscreen windows.

此特性是 true if the platform defaults to windows being fullscreen, otherwise false .

注意: The platform may still choose to show certain windows non-fullscreen, such as popups or dialogs. This property only reports the default behavior.

訪問函數:

bool showIsFullScreen () const

另請參閱 QWindow::show () 和 showIsMaximized ().

[read-only] showIsMaximized : const bool

This property holds whether the platform defaults to maximized windows.

此特性是 true if the platform defaults to windows being maximized, otherwise false .

注意: The platform may still choose to show certain windows non-maximized, such as popups or dialogs. This property only reports the default behavior.

訪問函數:

bool showIsMaximized () const

另請參閱 QWindow::show () 和 showIsFullScreen ().

showShortcutsInContextMenus : bool

true if the platform normally shows shortcut key sequences in context menus, otherwise false .

Since Qt 5.13, the setShowShortcutsInContextMenus() function can be used to override the platform default.

訪問函數:

bool showShortcutsInContextMenus () const
void setShowShortcutsInContextMenus (bool showShortcutsInContextMenus )

通知程序信號:

void showShortcutsInContextMenusChanged (bool)

另請參閱 Qt::AA_DontShowShortcutsInContextMenus .

[read-only] singleClickActivation : const bool

This property holds whether items are activated by single or double click.

此特性是 true if items should be activated by single click, false if they should be activated by double click instead.

訪問函數:

bool singleClickActivation () const

[read-only] startDragDistance : const int

This property holds the distance, in pixels, that the mouse must be moved with a button held down before a drag and drop operation will begin.

若應用程序支持拖放,且想要開始拖放操作在用戶有按下按鈕將光標移動一定距離後,應使用此特性值作為最小要求距離。

例如,若將點擊鼠標位置存儲在 startPos 且當前位置 (如:在鼠標移動事件中) 為 currentPos , 可以找齣是否應采用像這樣的代碼啓動拖拽:

if ((startPos - currentPos).manhattanLength() >=
        QApplication::startDragDistance())
    startTheDrag();
					

訪問函數:

int startDragDistance () const

通知程序信號:

void startDragDistanceChanged (int startDragDistance )

另請參閱 startDragTime , QPoint::manhattanLength (),和 拖放 .

[read-only] startDragTime : const int

This property holds the time, in milliseconds, that a mouse button must be held down before a drag and drop operation will begin.

若應用程序支持拖放,且想要開始拖放操作在用戶有按下鼠標按鈕一定時間後,應使用此特性值作為延遲。

訪問函數:

int startDragTime () const

通知程序信號:

void startDragTimeChanged (int startDragTime )

另請參閱 startDragDistance and 拖放 .

[read-only] startDragVelocity : const int

This property holds the limit for the velocity, in pixels per second, that the mouse may be moved, with a button held down, for a drag and drop operation to begin. A value of 0 means there is no such limit.

訪問函數:

int startDragVelocity () const

另請參閱 startDragDistance and 拖放 .

[read-only] tabFocusBehavior : const Qt::TabFocusBehavior

This property holds the focus behavior on press of the tab key.

注意: Do not bind this value in QML because the change notifier signal is not implemented yet.

訪問函數:

Qt::TabFocusBehavior tabFocusBehavior () const

通知程序信號:

void tabFocusBehaviorChanged (Qt::TabFocusBehavior tabFocusBehavior )

[read-only] touchDoubleTapDistance : const int

This property holds the maximum distance, in pixels, that a finger can be moved between two consecutive taps and still have it detected as a double-tap

訪問函數:

int touchDoubleTapDistance () const

useHoverEffects : bool

This property holds whether UI elements use hover effects.

此特性是 true if UI elements should use hover effects. This is the standard behavior on desktop platforms with a mouse pointer, whereas on touch platforms the overhead of hover event delivery can be avoided.

訪問函數:

bool useHoverEffects () const
void setUseHoverEffects (bool useHoverEffects )

通知程序信號:

void useHoverEffectsChanged (bool useHoverEffects )

[read-only] useRtlExtensions : const bool

此特性保持書寫方嚮。

此特性是 true if right-to-left writing direction is enabled, otherwise false .

訪問函數:

bool useRtlExtensions () const

[read-only] wheelScrollLines : const int

Number of lines to scroll by default for each wheel click.

訪問函數:

int wheelScrollLines () const

通知程序信號:

void wheelScrollLinesChanged (int scrollLines )

成員函數文檔編製

[since 6.8] void QStyleHints:: setColorScheme ( Qt::ColorScheme scheme )

Sets the color scheme used by the application to an explicit scheme , or revert to the system's current color scheme if scheme is Qt::ColorScheme::Unknown .

注意: setter 函數對於特性 colorScheme .

該函數在 Qt 6.8 引入。

另請參閱 colorScheme ().

[since 6.8] void QStyleHints:: unsetColorScheme ()

Restores the color scheme to the system's current color scheme.

注意: resetter 函數對於特性 colorScheme .

該函數在 Qt 6.8 引入。