c++ - Permanently disable shift in Qt when the GUI is running? -


I am using a QTableView where a list of Icons appears, something with the user mouse and the control key button I can select the mouse, and I am able to handle these selections. But I want to use the change to disable the left mouse key on Qualable Wid.

Is there any way to completely disable the shift key button during this process, when a GUI is being run? I am able to locate the shift key using the event filter which is installed on the viewport of the QTableView, but when there is no way to completely disable the shift key by pressing the shift key and left mouse button to the user user Can get it.

My event filter is as below:

  bool MainWindow :: eventFilter (QObject * obj, QEvent * EV) {if (obj == UI-> ; ListOfImages- & gt; Viewport ()) (if (eve-> type () == QEvent :: MouseButtonPress) {QMouseEvent * mouseEv = static_cast  (EV); if ((mouseEv - & gt; Button () & amp; QT :: LeftButton & amp; QApplication :: keyboardModifiers () testFlag (QT :: ControlModifier) ​​== true) & amp; QApplication :: keyboardModifiers () .testflag (Qt :: ShiftModifier) ​​== incorrect)) {controlButtonCounter ++; Fetch = true; // For some purposes I'll use these variables return to QObject :: eventFilter (obj, Ev);} Else if ((mouseEv-> button () & QT :: LeftButton) & amp; QApplication :: keyboardModifiers () testFlag (QT :: ControlModifier) ​​== incorrect) & amp;; Amp; (QApplication ::. KeyboardModifiers () testFlag (QT :: ShiftModifier) ​​== incorrect)) {if (selectedImages.size ()> 0) {UI-> ListOfImages- & gt; ClearSelection (); SelectedImages.clear (); SelectedList.clear (); UI- & gt; SelectedFiles-> clear (); UI- & gt; SelectedFiles-> Show (); } Fetch = false; ControlButtonCounter = 0; // I use these variables for some purposes) Else if ((mouseEv-> Button () & QT :: LeftButton & amp; QApplication :: keyboardModifiers () testFlag (QT :: ControlModifier) ​​== incorrect) & amp;; QApplication :: Keyboard Modifier (.) TestFlag (Qt :: ShiftModifier) ​​== true)) {qDebug () & lt; & Lt; "Press the Shift button!"; // Do not use multiple icons to prevent shift button. }}} Return QObject :: eventFilter (obj, ev); }  

I handle the mouse click and button position in the following way:

MyWidget :: eventFilter (QObject * obj, QEvent * event) {[...] If (Event> Type =) QEvent :: MouseButtonPress || Event & gt; Type () == QEvent :: MouseButtonRelease) {Qt :: KeyboardModifiers Modifiers = QApplication :: Keyboard Modifiers (); If (modifier & amp; Qt :: ShiftModifier) ​​{// filter the event, when the mouse is pressed / released / / return true by pressing the Shift key; } } [..] return false; }

Comments