Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Add a movable tableview to a qt scene

Add a movable tableview to a qt scene

Scheduled Pinned Locked Moved Solved General and Desktop
qt desktopqgraphicssceneqtableviewqt widget
3 Posts 2 Posters 479 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sachinrd
    wrote on 14 Jun 2021, 17:21 last edited by
    #1

    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);```
    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 14 Jun 2021, 18:30 last edited by
      #2

      Hi,

      Please these a look at this stack overflow answer.

      The idea there goes in a good direction.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • S Offline
        S Offline
        sachinrd
        wrote on 16 Jun 2021, 05:01 last edited by
        #3

        Thanks for the reply @SGaist . This helps

        1 Reply Last reply
        0

        2/3

        14 Jun 2021, 18:30

        • Login

        • Login or register to search.
        2 out of 3
        • First post
          2/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved