Results 1 to 3 of 3

Thread: QGraphicsScene problem/bug

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2009
    Posts
    30
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default QGraphicsScene problem/bug

    Taken directly from the Qt 4.5.2 documentation, in the Detailed Description of QGraphicsGridLayout:

    Qt Code:
    1. QGraphicsWidget *textEdit = scene.addWidget(new QTextEdit);
    2. QGraphicsWidget *pushButton = scene.addWidget(new QPushButton);
    3.  
    4. QGraphicsGridLayout *layout = new QGraphicsGridLayout;
    5. layout->addItem(textEdit, 0, 0);
    6. layout->addItem(pushButton, 0, 1);
    7.  
    8. QGraphicsWidget *form = new QGraphicsWidget;
    9. form->setLayout(layout);
    10. scene.addItem(form);
    To copy to clipboard, switch view to plain text mode 

    First problem: I don't see anything if I wrap this in a simple QApplication:
    Qt Code:
    1. int main()
    2. {
    3.  
    4. QWidget *widget;
    5. //the above code, with the first line:
    6. //QGraphicsScene scene(widget);
    7. widget->show();
    8. return app.exec();
    9. }
    To copy to clipboard, switch view to plain text mode 

    This structure is really important, but when I try to implement it in my class's constructor, it won't compile. What's wrong here? Thanks!
    Last edited by rubenvb; 27th September 2009 at 16:40.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QGraphicsScene problem/bug

    ..you don't see anything because you have to show the scene or set it to your widget, using layouts!
    Qt Code:
    1. int main()
    2. {
    3. //the above code
    4. scene.show();
    5. return app.exec();
    6. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsScene problem/bug

    It might be worth actually having a QGraphicsView somewhere...
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QGraphicsScene core dump?
    By cookie1909 in forum Newbie
    Replies: 2
    Last Post: 25th April 2009, 07:06
  2. Replies: 0
    Last Post: 5th March 2009, 06:54
  3. QPixmap display on QGraphicsScene
    By febil in forum Qt Programming
    Replies: 2
    Last Post: 26th February 2009, 09:27
  4. in QGraphicsScene matrix of other QGraphicsScene
    By Noxxik in forum Qt Programming
    Replies: 5
    Last Post: 15th February 2009, 17:27
  5. When to use QGraphicsScene or QWidget
    By fossill in forum Qt Programming
    Replies: 2
    Last Post: 9th February 2007, 23:58

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.