qtqtablewidgetmouseclick-eventmodifier-key

How to detect the modifier key on mouse click


I have a QTableWidget and would like that pressing Ctrl while clicking on a column header, marks the whole column.

To get the column index is not a problem, since there is a sectionPressed signal, which gives me the current index of the column clicked.

How can I get the state of any keyboard modifiers when a column is clicked?


Solution

  • On Qt 4, try QApplication::keyboardModifiers().

    The Qt 5 and Qt 6 equivalent is QGuiApplication::keyboardModifiers().