Results 1 to 11 of 11

Thread: Putting all widgets in QGraphicsView using QGraphicsProxyWidgets - Good idea?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,328
    Thanks
    317
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Putting all widgets in QGraphicsView using QGraphicsProxyWidgets - Good idea?

    Giving a widget as a parent is safe because when an object is deleted, it is being detached from the parent so the parent will not delete it again.
    Yes, I knew that. Since your post and my edit crossed in the aether, what about my conjecture concerning the proxy / widget / scene interaction? One would think that if a QWidget deletion resulted in the deletion of its graphics proxy, that would also clean up the scene.

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

    Default Re: Putting all widgets in QGraphicsView using QGraphicsProxyWidgets - Good idea?

    I don't think the widget deletes its proxy. Unless of course you reparent it to the widget. This is just my guess, of course. As for the original problem it seems to me it is enough to see the debugger backtrace from the crash. All should be obvious then.
    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.


  3. #3
    Join Date
    Oct 2011
    Posts
    14
    Qt products
    Platforms
    Windows

    Default Re: Putting all widgets in QGraphicsView using QGraphicsProxyWidgets - Good idea?

    Thanks for the answers, I managed to get rid of the error. Instead of letting my center widget call qApp.quit(), I now let it call another function, that loops through the QGraphicsProxyWidgets and close()s them and finally close the QGraphicsView. I'm really not an expert in PyQt's parent relationship, right now I'm creating my widgets without parents and then put them into QGraphicProxyWidgets (setWidget()), which seems to work fine. Should I reparent them somehow?

    Anyways, everything works just the way I want it right now, and looking at my original question, I think it's the best approach, as I don't have to worry much about propagating events between the three embedded widgets and everything is wrapped up inside the QGraphicsView, which means I have only one entry in the taskbar.

    And I think I should really give QtQuick a try, the summary sounds nice, thanks for pointing me to it, wysota.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,328
    Thanks
    317
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Putting all widgets in QGraphicsView using QGraphicsProxyWidgets - Good idea?

    Should I reparent them somehow?
    Doesn't seem like it, although if Qt is doing the parenting properly in the first place, you shouldn't have to loop through anything to destroy objects manually. Simply deleting the scene (if it is heap allocated) or allowing it to go out of scope (if stack allocated) should result in all items in the scene being cleanly destroyed and all views being disconnected from the scene. I have never had need to use QGraphicsProxyWidget, so I don't know what happens in that case. Probably would help to comment out your manual cleanup code and see what happens (using the debugger) when Qt goes through its normal shutdown.

Similar Threads

  1. Exception handling in external library - good or bad idea
    By kornicameister in forum Qt Programming
    Replies: 0
    Last Post: 20th February 2012, 14:25
  2. Replies: 2
    Last Post: 4th July 2010, 22:49
  3. Is creating yet another IDE a good idea?
    By piotr.dobrogost in forum Qt Tools
    Replies: 20
    Last Post: 31st July 2009, 07:38
  4. Replies: 1
    Last Post: 16th July 2009, 02:25

Tags for this Thread

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.