Qt: how to determine the Cmd + key combination for MAC

I am completely new to Qt.

How to determine Cmd + numeric key sequence on Mac in code?

For windows i have

 QKeySequence(QString("Ctrl+") + QString::number(number)); 

where number is, say, 2

What should be the same for the cmd MAC key?

And is it possible for Qt to be somehow defined if we are working on a Mac or Windows (so that I can create a sequence of keys if necessary)?

+6
source share
1 answer

As noted in the Qt::Modifier documentation listing :

Note. On Mac OS X, the CTRL value corresponds to the Macintosh keyboard commands, and the META value corresponds to the Keys control.

More about the QKeySequence documentation :

Note. On Mac OS X, references to "Ctrl", Qt :: CTRL, Qt :: Control and Qt :: ControlModifier correspond to commands on the Macintosh keyboard and links to "Meta", Qt :: META, Qt :: Meta and Qt :: MetaModifier corresponds to the control keys. Developers on Mac OS X can use the same shortcut descriptions on all platforms, and their applications will automatically run as expected on Mac OS X.

So, if you just use Ctrl for Windows / Linux and Cmd on MacOS, you don’t need to change anything, just use the Windows sequence.

+9
source

Source: https://habr.com/ru/post/946067/


All Articles