Your line number 3) has a bug. You Control key check must be a field manipulation operator(&) and not (&&). The correct line of code would be:
if ((e
->key
() == Qt
::Key_F) && (QApplication::keyboardModifiers() & Qt
::ControlModifier))
if ((e->key() == Qt::Key_F) && (QApplication::keyboardModifiers() & Qt::ControlModifier))
To copy to clipboard, switch view to plain text mode
Another way to do the same for people who are not that familiar with field manipulation functions is the following line identical to the line above:
if ((e
->key
() == Qt
::Key_F) && (QApplication::keyboardModifiers().
testFlag(Qt
::ControlModifier)))
if ((e->key() == Qt::Key_F) && (QApplication::keyboardModifiers().testFlag(Qt::ControlModifier)))
To copy to clipboard, switch view to plain text mode
I would also recommend using the modifiers coming from the key event itself and not the global app keyboard modifiers. i.e. the best way to write what you need is:
if ((e->key() == Qt::Key_F) && (e->modifiers().testFlag(Qt::ControlModifier)))
if ((e->key() == Qt::Key_F) && (e->modifiers().testFlag(Qt::ControlModifier)))
To copy to clipboard, switch view to plain text mode
Bookmarks