qxtglobalshortcut
Public Slots | Signals | Public Member Functions | Properties | Friends | List of all members
QxtGlobalShortcut Class Reference

The QxtGlobalShortcut class provides a global shortcut aka "hotkey". More...

Inheritance diagram for QxtGlobalShortcut:

Public Slots

void setEnabled (bool enabled=true)
 
void setDisabled (bool disabled=true)
 

Signals

void activated (QxtGlobalShortcut *self)
 

Public Member Functions

 QxtGlobalShortcut (QObject *parent=nullptr)
 
 QxtGlobalShortcut (const QKeySequence &shortcut, QObject *parent=nullptr)
 
 ~QxtGlobalShortcut ()
 
QKeySequence shortcut () const
 
bool setShortcut (const QKeySequence &shortcut)
 
bool isEnabled () const
 
bool isValid () const
 

Properties

bool enabled
 whether the shortcut is enabled More...
 
bool valid
 whether the shortcut was successfully set up
 
QKeySequence shortcut
 the shortcut key sequence More...
 

Friends

class QxtGlobalShortcutPrivate
 

Detailed Description

The QxtGlobalShortcut class provides a global shortcut aka "hotkey".

A global shortcut triggers even if the application is not active. This makes it easy to implement applications that react to certain shortcuts still if some other application is active or if the application is for example minimized to the system tray.

Example usage:

connect(shortcut, SIGNAL(activated()), window, SLOT(toggleVisibility()));
shortcut->setShortcut(QKeySequence("Ctrl+Shift+F12"));

Constructor & Destructor Documentation

§ QxtGlobalShortcut() [1/2]

QxtGlobalShortcut::QxtGlobalShortcut ( QObject *  parent = nullptr)
explicit

Constructs a new QxtGlobalShortcut with parent.

§ QxtGlobalShortcut() [2/2]

QxtGlobalShortcut::QxtGlobalShortcut ( const QKeySequence &  shortcut,
QObject *  parent = nullptr 
)
explicit

Constructs a new QxtGlobalShortcut with shortcut and parent.

§ ~QxtGlobalShortcut()

QxtGlobalShortcut::~QxtGlobalShortcut ( )

Destructs the QxtGlobalShortcut.

Member Function Documentation

§ activated

QxtGlobalShortcut::activated ( QxtGlobalShortcut self)
signal

This signal is emitted when the user types the shortcut's key sequence.

See also
shortcut

§ setDisabled

void QxtGlobalShortcut::setDisabled ( bool  disabled = true)
slot

Sets the shortcut disabled.

See also
enabled

§ setEnabled

void QxtGlobalShortcut::setEnabled ( bool  enabled = true)
slot

Sets the shortcut enabled.

See also
enabled

Property Documentation

§ enabled

QxtGlobalShortcut::enabled
readwrite

whether the shortcut is enabled

A disabled shortcut does not get activated.

The default value is true.

See also
setEnabled(), setDisabled()

§ shortcut

QxtGlobalShortcut::shortcut
readwrite

the shortcut key sequence

sets the shortcut key sequence

Notice that corresponding key press and release events are not delivered for registered global shortcuts even if they are disabled. Also, comma separated key sequences are not supported. Only the first part is used:

qxtShortcut->setShortcut(QKeySequence("Ctrl+Alt+A,Ctrl+Alt+B"));
Q_ASSERT(qxtShortcut->shortcut() == QKeySequence("Ctrl+Alt+A"));
See also
setShortcut()
shortcut()

The documentation for this class was generated from the following files: