Results 1 to 4 of 4

Thread: problem using qgraphicsview

  1. #1
    Join Date
    Jul 2009
    Posts
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Question problem using qgraphicsview

    QGraphicsScene s;
    s.addText("hello"); //s.addRect(0,0,100,100);
    QGraphicsView v(&s);
    v.show();

    i am using qt4.5 , i try to write a simple qt program using qt creator to display a view containing a scene with text or a rectagle , when i run it its displaying only a blank view neither text or a rectangle being drawn.

    can any body help

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: problem using qgraphicsview

    This is working fine on my machine.
    Qt Code:
    1. #include <QApplication>
    2. #include <Qtgui>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. s.addText("hello"); //s.addRect(0,0,100,100);
    8. v.show();
    9. return a.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: problem using qgraphicsview

    Quote Originally Posted by sandhyarani View Post
    QGraphicsScene s;
    s.addText("hello"); //s.addRect(0,0,100,100);
    QGraphicsView v(&s);
    v.show();

    i am using qt4.5 , i try to write a simple qt program using qt creator to display a view containing a scene with text or a rectagle , when i run it its displaying only a blank view neither text or a rectangle being drawn.

    can any body help
    You sure it doesn't go out of score with everything on stack? Try to put it in heap and see what happen...

  4. #4
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: problem using qgraphicsview

    Quote Originally Posted by lni View Post
    You sure it doesn't go out of score with everything on stack?
    Yes I am, because app.exec() is the barrier here. untill you dont terminate application execution, these objects will be in memory, and the program is running absolutely fine.
    Quote Originally Posted by lni View Post
    Try to put it in heap and see what happen...
    Same results.

Similar Threads

  1. Replies: 2
    Last Post: 26th February 2009, 10:12
  2. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  3. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 10:35
  4. Problem determining size of QGraphicsView
    By Bocki in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2008, 14:54
  5. Smooth pixmap transform in QGraphicsView problem
    By spud in forum Qt Programming
    Replies: 1
    Last Post: 24th October 2007, 16:47

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.