Results 1 to 3 of 3

Thread: QWidgets inside QGraphicsWidget [parent issue]

  1. #1
    Join Date
    Mar 2012
    Location
    Germany
    Posts
    17
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QWidgets inside QGraphicsWidget [parent issue]

    Hello,

    I don't know if the problem is due to bad design or anything...
    However, I have a subclass of QGraphicsWidget. Now I want to add some widgets to the subclass (here: QProgressBar)
    and it works to some extend; they appear but aren't in my QGraphicsScene which my subclass is part of (via addItem()) .

    I came to the conclusion that the problem has to be that the widgets inside my subclass don't have a parent.
    Now I could call widget_inside_subclass.setParent(this), but they only accept QObjects* and my subclass is a QGraphicsWidget.

    Is there a way to "force" them to be my subclass' child's?
    Even better solutions are also welcome.

    Thanks.

    - jovin

  2. #2
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QWidgets inside QGraphicsWidget [parent issue]

    Quote Originally Posted by jovin View Post
    . . . but they only accept QObjects* and my subclass is a QGraphicsWidget.
    I don't understand the problem since: QObject <- QGraphicsObject <- QGraphicsWidget

    Anyway, try putting your widgets in the layout of the QGraphicsWidget. There is a good example in the docs, here.

  3. #3
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QWidgets inside QGraphicsWidget [parent issue]

    Also take a look at QGraphicsProxyWidget.

Similar Threads

  1. Replies: 14
    Last Post: 18th June 2011, 10:32
  2. Replies: 0
    Last Post: 16th January 2011, 02:35
  3. Dreaded Diamond Issue with QGraphicsWidget and QObject
    By perden in forum Qt Programming
    Replies: 5
    Last Post: 18th June 2010, 19:54
  4. Layering QWidgets inside a QWidget
    By bunjee in forum Qt Programming
    Replies: 2
    Last Post: 2nd November 2008, 18:25
  5. Issue with masking QWidgets
    By JimDaniel in forum Qt Programming
    Replies: 6
    Last Post: 2nd November 2007, 19:23

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.