Results 1 to 3 of 3

Thread: Issues with QGraphicsView show() called from function other than main()

  1. #1
    Join Date
    Feb 2010
    Posts
    99
    Thanks
    31
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Issues with QGraphicsView show() called from function other than main()

    Hi,

    I am using QGraphicsView (which has QGraphicsScene containing the widgets) for my UI. In main() I create QGraphicsView object and set the scene and add widgets to it. Then I call show() on QGraphicsView. This setup works fine.
    Now I move the QGrahicsView and related setup to a separate class and expose a function loadUI() which will be called from the main() to load the UI. When I call loadUI(), the UI come for a fraction of section and then goes away. The application is still running but no UI.

    What is wrong with my new setup?

    Thanks.

  2. #2
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Issues with QGraphicsView show() called from function other than main()

    Sounds like you're creating your QGraphicsScene in your class function. Once the function terminates, local variables are destroyed, along with your scene.

    Code would be helpful.

  3. The following user says thank you to SixDegrees for this useful post:

    dpatel (15th July 2010)

  4. #3
    Join Date
    Feb 2010
    Posts
    99
    Thanks
    31
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Issues with QGraphicsView show() called from function other than main()

    Ahh very basic principle of object lifetime. Thanks for pointing that out. I verified, and that was the only issue.

Similar Threads

  1. Replies: 2
    Last Post: 6th July 2010, 13:35
  2. error message appears when function is called
    By babygal in forum Qt Programming
    Replies: 11
    Last Post: 14th June 2010, 23:49
  3. wrong virtual function called at some events on MacOS?
    By akos.maroy in forum Qt Programming
    Replies: 0
    Last Post: 3rd July 2009, 11:06
  4. QString - no member function called 'find'
    By pitterb in forum Newbie
    Replies: 1
    Last Post: 13th January 2009, 11:31
  5. Replies: 4
    Last Post: 10th March 2007, 18:01

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.