PDA

View Full Version : Different delegates to different Columns of QTableView.



kaushal_gaurav
6th August 2008, 08:24
Hi,

How can i apply different delegates to different columns of QTableView.
I have a QTableView of two Columns (say col_1 and col_2)
Now i have to put comboBox in each cell of col_1 and col_2 but the data of comboBox in col_1 differ from data in comboBox of col_2.
The data is to be read from the Modal.

Please help

zlosynus
6th August 2008, 08:34
Hi,

I beleave this can help you. Just create different delegate classes and then use QTableView::setItemDelegateForColumn (http://doc.trolltech.com/4.4/qabstractitemview.html#setItemDelegateForColumn).

aamer4yu
6th August 2008, 08:40
I dont think u will need to use different delegates. You can use internalPointer for a given index to retrieve the data for populating the combobox

kaushal_gaurav
6th August 2008, 08:54
if i use QTableView::setItemDelegateForColumn then inside CreateEditor function i can not find for which row i need to populate the combo....

aamer4yu - How can i use internal pointer?
When would in put data inside the internal pointer?

Some example!

aamer4yu
6th August 2008, 09:17
You may refer to Simple DOM Model or Simple Tree Model in the Qt Demos.
You will get some idea how to store data of ur own type via internalPointer :)