PDA

View Full Version : QPushButton in QItemDelegate



allbabel
2nd April 2009, 11:45
Hi,

This is my first post to the list so please be gentle.

I want to create a QItemDelegate for a QListView that draws some text and a QPushButton. So far I can draw the text and QPushButton within the paint method of QItemDelegate.

The issue I have is I want to respond to clicks on the button. I am aware it isn't a real button but simply a graphic representation of it, what is the best route here? Build my own event handler for the painted button?

For QListView I could use setItemWidget but that seems to be a bit over the top and if my list view gets large, which it may, then there would be a performance hit, right?

I have found this link (http://www.qtcentre.org/forum/f-qt-programming-2/t-drawing-a-widget-in-qitemdelegates-paint-method-8660.html) which discusses this in depth but it doesn't address the issue of connecting to a QPushButton.

Thanks in advance
Andy