简体   繁体   中英

Global short cut key for a QPushButton

How could I register a global short cut key for a certain QPushButton? Especially when the QPushButton is not a direct child of the main window.

You mean

QKeySequence

QShortcut

classes? Or do you just need something more powerful?

Usually you create a QAction and you add it to a menu or a toolbar. You can set a shortcut, icon, tooltip etc, this is not exactly a QPushButton but it's pretty close and it is easy to link your action to any slot of your convenience.

But if you just want to capture a shortcut or a key to steal it from the OS, MasterAler is right, go for QKeySequence or QShortcut .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM