Results 1 to 4 of 4

Thread: Why QFrame does not resize on QgraphicsScene?

  1. #1
    Join Date
    Mar 2019
    Posts
    7
    Thanks
    1
    Qt products
    Qt5

    Default Why QFrame does not resize on QgraphicsScene?

    Hi,

    I have a QGraphicsScene to which I would like to add a QFrame. I'm doing so by calling the addWidget function of the QgraphicsScene class.
    On the created QFrame I've added a grid layout which contains QGraphicsWidget classes.

    Why the QFrame always keeps its size? If I have a small number of elements in the layout it fits well inside the QFrame but
    as soon as I add too much elements the widgets go outside of the boundaries of the QFrame. (I can stell see them because the QGraphicsView scrolls but outside of the frame)

    Actually my goal is the having a border around my grid layout.

    Do you have any ideas?

    Thanks
    Last edited by Manuka; 4th April 2019 at 15:25.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,396
    Thanks
    37
    Thanked 1,542 Times in 1,493 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Why QFrame does not resize on QgraphicsScene?

    That sounds like a broken approach, so maybe it is better if you describe what your goals are.

    If you add a container widget like a QFrame you would add widgets to it, not graphic items. A container widgets knows nothing about graphics items, it only deals with child widgets.

    Cheers,
    _

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

    Manuka (5th April 2019)

  4. #3
    Join Date
    Mar 2019
    Posts
    7
    Thanks
    1
    Qt products
    Qt5

    Default Re: Why QFrame does not resize on QgraphicsScene?

    Thank you for your response.

    I have a QGraphicsGridLayout with objects classes inheriting from QGraphicsWidget. My goal is to have a rectangle as a border around my QGraphicsGridLayout

    Thanks!


    Added after 51 minutes:


    I thought another solution may be to inherit from QGraphicsWidget. Then set my grid layout on. Finally to override the paint function by calling the base class paint function QGraphicsWidget:aint() and then drawing a rectangle defined by the bounding rect.
    Last edited by Manuka; 5th April 2019 at 13:00.

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,396
    Thanks
    37
    Thanked 1,542 Times in 1,493 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Why QFrame does not resize on QgraphicsScene?

    Quote Originally Posted by Manuka View Post
    then drawing a rectangle defined by the bounding rect.
    Or use a QGraphicsRectItem

    Cheers,
    _

Similar Threads

  1. how to make the QGraphicsScene resize automaticly
    By reboot in forum Qt Programming
    Replies: 3
    Last Post: 8th May 2017, 00:08
  2. QFrame doesn't resize as it should
    By navieh in forum Qt Programming
    Replies: 1
    Last Post: 1st April 2013, 10:48
  3. Replies: 1
    Last Post: 24th March 2011, 04:29
  4. How to resize a QGraphicsScene to a QGraphicsView?
    By CassioTC in forum Qt Programming
    Replies: 2
    Last Post: 22nd March 2011, 09:03
  5. QFrame with border-radius inside QGraphicsScene
    By DeRatizator in forum Qt Programming
    Replies: 2
    Last Post: 23rd August 2010, 08:39

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