SOLVED :is there such a thing as QGraphicsTableItem you can add to a QGraphicsScene?



  • Hi,
    I need to implement an editable table in my application(based on the QGraphicsScene/QGraphicsView Framework) and I was looking in the doc for something to start off with but haven''t found anything attractive so far.I was wondering if anybody knew if there is something I can inherit from or any other piece of work I can use to get the job done.

    Thanks for your input.


  • Lifetime Qt Champion

    Hi,

    Is adding a QTableWidget to your scene a possible solution ?



  • Thanks for the reply SGaist,
    QTableWidget has all the things I need but I have trouble transforming it to a QGraphicsItem so I can add it to the scene.I there a way I can do this?
    Thanks again for the input.


  • Moderators

    QGraphicsProxyWidget ;)
    You may also want to check the "examples":http://qt-project.org/doc/qt-5/qtwidgets-graphicsview-embeddeddialogs-example.html



  • Thanks guys ,this looks like what I need .



  • Hi again,
    I tried your suggestion guys and the Widget can be added to my scene.But i still have one problem.My new widget in the scene can't take advantage of the features of the scene such us the being moved in the scene when the isMovable floag is applied.I added the widget as follows
    @
    //mProxy is a QGraphicsProxyWidget pointer defined
    //in my header.
    mProxy=testScene->addWidget(tableContainerWidget);
    mProxy->translate(300,0);
    mProxy->setFlag(QGraphicsItem::ItemIsMovable);

    @

    Any help will be appreciated.
    Thanks.


  • Moderators

    when your widget consumes the mouse event you wont be able to move the item in the scene. You will need to add something like a frame to move it. Like you would do for frameless top-level windows.



  • Thanks for the quick reply,
    [quote author="raven-worx" date="1377498099"]. You will need to add something like a frame to move it. Like you would do for frameless top-level windows.[/quote]

    I apologize if this is obvious but how exactly can I add a frame to a widget ,and how does the frame help in moving the widget in the scene.
    Thanks again.


  • Moderators

    You should rather create a frame by adding a QGraphicsItem to your scene with your QGraphicsProxyWidget as a child-item.



  • Thanks,I can now move them in my scene.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.