How to determine if there was a double click on a QWidget (QStatusBar, in my case) when the modifier key was held?
I can overload void QWidget::mouseDoubleClickEvent ( QMouseEvent * event )to get a double click, but how can I make sure the widget receives key events when it may not have focus?
void QWidget::mouseDoubleClickEvent ( QMouseEvent * event )
I found the answer:
QMouseEventobtained from QInputEventand has a method called modifiers():
QMouseEvent
QInputEvent
modifiers()
From the Qt Documentation :
Returns the keyboard modifier flags that existed immediately before the event occurred.
SLOT (Mouse) , :
Qt::KeyboardModifiers modifiers = QApplication::queryKeyboardModifiers (); if(modifiers.testFlag( Qt::ControlModifier )){ qDebug() << "CTRL was hold when this function was called"; } else{ qDebug() << "CTRL wasn't hold"; } //SHIFT = Qt::ShiftModifier //CTRL = Qt::ControlModifier //ALT = Qt::AltModifier
QWidget
protected: void mouseDoubleClickEvent(QMouseEvent *event);
Source: https://habr.com/ru/post/1732545/More articles:Which behavior is preferable? (Embedding Python) - pythonSetting CTreeCtrl for Partial State - user-interfaceWhen is it appropriate to use accordions? - jqueryПри каких обстоятельствах необходимо выполнить явное преобразование переменной в строку в JavaScript? - javascripthttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1732544/sql-server-2005-dynamically-adding-parameters-to-a-stored-procedure&usg=ALkJrhgt_tpknulS83t8O3rKtZxld2-xBgIBAction methods declared in the protocol are not visible in Interface Builder - objective-chttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1732547/in-the-command-pattern-what-do-you-call-a-command-that-groups-together-other-commands&usg=ALkJrhhzJXSawMj58XdoJxOFRspqhbSXHAHow can I configure the Java system for JNLP applications? - javaHow to automatically launch the necessary services and applications? - erlangZend Framework: how to POST data to any external page (for example, an external payment gateway) without using a form? - redirectAll Articles