Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to avoid mouse click on one widget triggering the signals in others in Qt?
    primarykey
    data
    text
    <p>In my app I'm using a QTableView to show a list of images and I select some of the images by clicking left mouse button and pressing control keyboard button when I do so the app looks as the below stated image:<img src="https://i.stack.imgur.com/PziMc.png" alt="enter image description here"></p> <p>But then when I try to use other buttons on the app like <strong>"Destination"</strong> and then try to select a destination folder then the app looks like this below: <img src="https://i.stack.imgur.com/NBYLX.png" alt="enter image description here"></p> <p>Problem occurs when I click the <strong>"select folder"</strong> button and try to select the folder. What happens is that click on the folder selection tab, triggers QTableView widget in which I show the image and the deselects all the selected images. I want to avoid it. The way I now track the left mouse button clicks on QTableView widget is as below:</p> <pre><code>bool MainWindow::eventFilter(QObject* obj, QEvent *ev) { if(obj == ui-&gt;listOfImages-&gt;viewport()) { QMouseEvent * mouseEv = static_cast&lt;QMouseEvent*&gt;(ev); if((mouseEv-&gt;buttons() &amp; Qt::LeftButton) &amp;&amp; (QApplication::keyboardModifiers().testFlag(Qt::ControlModifier) == true)) { controlButtonCounter++; fetch = true; return QObject::eventFilter(obj,ev); } else if((mouseEv-&gt;buttons() &amp; Qt::LeftButton) &amp;&amp; (QApplication::keyboardModifiers().testFlag(Qt::ControlModifier) == false)) { if(selectedImages.size()&gt;0) { ui-&gt;listOfImages-&gt;clearSelection(); selectedImages.clear(); } fetch = false; controlButtonCounter = 0; } } return QObject::eventFilter(obj,ev); } </code></pre> <p>Here <code>ui-&gt;listOfImages</code> is the QTableView widget. Other things like <code>controlButtonCounter</code> are irrelevant in taking the mouse clicks, I use it for other purposes. </p> <p>Please say me how I can avoid triggering QTableView widget when I'm pressing on other things that fall in the same region as the QTableView.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload