Add a movable tableview to a qt scene
Solved
General and Desktop
-
Hello,
I have a graphics scene and i want to add a tableview to the scene such that the tableview is draggable and movable within the scene rect. Can someone help me how i can achieve this ?
Thanks for any help in advance .
Note: I did try adding a table view widget to the scene and setting the QGraphicsItem::ItemIsMovable flag on the proxy. No luck till now.
Here is a sample code snippet that i have tried:notesPageModel=new QStandardItemModel(); notesPageModel->setItem(0,0,new QStandardItem("REFERENCE NAME")); notesPageModel->setItem(0,1,new QStandardItem("VALUE")); notesPageModel->setItem(0,2,new QStandardItem("UNIT")); notesPageModel->setItem(0,3,new QStandardItem("REMARKS")); notesPageTableView=new QTableView(); notesPageTableView->setModel(notesPageModel); notesPageTableView->horizontalHeader()->setVisible(false); notesPageTableView->verticalHeader()->setVisible(false); notesPageTableView->setStyleSheet("QTableView::item{border : 2px solid black}"); notesPageTableView->resizeColumnsToContents(); QGraphicsProxyWidget *proxy1 = scene->addWidget(notesPageTableView); proxy1->setZValue(2); proxy1->setFlags(QGraphicsItem::ItemIsSelectable|QGraphicsItem::ItemIsMovable); notesPageTableView->setGeometry(0,0,900,600);```
-