×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    102

    QGraphicsWidget on QGraphicsObject

    Hi to All, in my project i create a QGraphicsObject that draw a chart and it shows it on the screen, to do this i've used a QGraphicsScene and QGraphicsView.
    Now i create a QGraphicsWidget and in its costructor I specified parent, my QGraphicsObject, but when i move QGraphicsObject (chart) my QGraphicsWidget doesn't move?
    What can i do to move they together?
    Thnaks a lot.

  2. #2
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QGraphicsWidget on QGraphicsObject

    The problem you've described doesn't exist.
    Code:
    #include <QApplication>
    #include <QGraphicsView>
    #include <QGraphicsScene>
    #include <QGraphicsProxyWidget>
    #include <QPushButton>
    #include <QDebug>
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
    
        QGraphicsProxyWidget *item1 = new QGraphicsProxyWidget();
        item1->setWidget(new QPushButton("Parent"));
        QGraphicsProxyWidget *item2 = new QGraphicsProxyWidget(item1);
        item2->setWidget(new QPushButton("Child"));
        QGraphicsProxyWidget *item3 = new QGraphicsProxyWidget();
        item3->setWidget(new QPushButton("Reference"));
    
        QGraphicsScene scene;
        scene.addItem(item1);
        scene.addItem(item3);
        item1->moveBy(100, 100);
        item2->setRotation(90.0);
    
        QGraphicsView view(&scene);
        view.show();
    
        return app.exec();
    }

Similar Threads

  1. Replies: 1
    Last Post: 2010-10-13, 05:22

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •