PDA

View Full Version : How do I get a pixmap to respond from being double clicked



ayanda83
2nd April 2015, 22:15
Hi there, I have a list of Pixmap in a QListView. My problem is that I want something to happen when I double click on a pixmap in the View. Please not that I did set the flags so that the pixmaps are selectable but I couldn't find anything about double clicking on them. Basically what I want is that when I double click on a pixmap, a signal gets sent. how can I implement that? NB: I created a custom model to hold the pixmaps in the QListView.

stampede
2nd April 2015, 22:34
I'm not an expert in the model/view stuff (so maybe there is a better solution), but I think you can simply connect to "QAbstractItemView::doubleClicked(const QModelIndex &)" signal to get notified about double click events on your view.

jefftee
2nd April 2015, 22:35
If the QPixmap is in a QLabel, then implement the QLabel::mouseDoubleClickEvent. If not in a QLabel, add it to a QLabel and see the first sentence. :)

Edit: missed the part about it being in a QListView. Do as @stampede suggested.

ayanda83
3rd April 2015, 06:46
thank you guys, works like a charm.