Capturing mouseEvents
-
I have a QTabWiget with three pages. On one page I have a QListWidget. I have implemented this to capture mouse events.
void NotebookView::mousePressEvent(QMouseEvent* event) { if(event->button == Qt::LeftButton) { printf("Left Mouse Button\n"); } }
The NotebookView is the QTabWidget. When I press the mouse outside the QListWidget, inside the QTabWidget, then I get a mouse event. What I really need is to get the event when I click inside the QListWidget. How do I get the event inside the QListWidget?
-
I have created a separate class of QListWidget instead of using qtcreator and now I can use the mouse events. Only how do I connect the QListWidget to the individual tab page?
-
Figured out the problem. this->widget(<page>) will assign the QListWidget to the QTabWidget.
-
I have done everything I can think of but I still can't select of the items in the list. Any ideas?
-
Just use the provided signal for your List widget item clicks.
Connect a function toitemClicked
and you're good. -
@gabello306 said in Capturing mouseEvents:
Any ideas?
Maybe because you've overridden the mousePressEvent?
Do you call inherited mousePressEvent in your mousePressEvent?