View Full Version : QTreeView item contains customised widget which is not working as I expected

15th February 2011, 11:26
Hi Everyone,
I am using a customised widget which contains 2 QPushButton and I have added that customised widget as a QTreeView item using setIndexWidget method. Now when I select the empty spaces in the customised widget I receive the signal
clicked ( QModelIndex ). But if I click on the QPushButton which is there in the customised widget dont give me any clicked ( QModelIndex ) signal, however I am receiving the normal clicked() signal for the QPushButton. Is there anyway to get the clicked(QModelIndex) signal clicking this QPushButton in the cutomised widget?

Any help will be appreciated.


15th February 2011, 13:49
Read documentation! See bottom of QAbstractItemView::setIndexWidget.

This function should only be used to display static content within the visible area corresponding to an item of data. If you want to display custom dynamic content or implement a custom editor widget, subclass QItemDelegate instead.

So use QAbstractItemView::setItemDelegate. See QAbstractItemDelegate

15th February 2011, 15:10
Thanks but I think what I was looking for is right and I found the solution from my code.