How to get the cell coordinates in QTableView
-
Hi All
I have created a TableView and on the click i want to get coordinates of the cell in which user has clicked and
create a combobox in that cell & combobox should fix exactly in that cell.How to do this?Here is my code
@
QStandardItem* item1 = new QStandardItem("Test1");
QStandardItem* item2 = new QStandardItem("Test2");Note: tablemodel_PT is of type QStandardItemModel*.
tablemodel_PT->insertRow(1 );
tablemodel_CA->setItem( row, 0, item1 );
tablemodel_CA->setItem( row, 1, item2 );
QComboBox* combo_PT = new QComboBox();
Note:tableView_PT is the object name of the TableView
QPoint point( 5 + ui.tableView_PT->columnViewportPosition ( col ) , ui.tableView_PT->rowViewportPosition(row) );
combo_PT->move( ui.tableView_PT->mapToGlobal(point) );
combo_PT->show();
@@
with above code when I am clicking in any of the cell the combobox is created but it is not place exactly in the cell in which it is clicked it is overlapping with adjacent cells.@ -
Maybe You take a look at
http://developer.qt.nokia.com/wiki/Combo_Boxes_in_Item_Viewsregards
karl-heinz -
These are relevant:
"Sections on delegate classes":http://developer.qt.nokia.com/doc/qt-4.8/model-view-programming.html#delegate-classes
Spinbox delegate "example":http://developer.qt.nokia.com/doc/qt-4.8/itemviews-spinboxdelegate.html
Color delegate factory "example":http://developer.qt.nokia.com/doc/qt-4.8/itemviews-coloreditorfactory.html