Results 1 to 6 of 6

Thread: Displaying bug with QGraphicsView in QGraphicsView

  1. #1
    Join Date
    Jul 2014
    Posts
    14
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Displaying bug with QGraphicsView in QGraphicsView

    Hello,

    I want to display hierarchical statecharts with QGraphicsViews.
    So every State can contain substates which in turn can i have also substates and so on.
    Each state displays its substates in a QGraphicsView, so there are QGraphicsViews in QGraphicsView in QGraphicsView...
    Each State inherits from QGraphicsItem and contains a QGraphicsProxyWidget which contains a Widget with a QGraphicsView.

    I tested it with a top level state, that contains two substates.
    Now comes the strange part:
    The first inserted substate is displayed perfectly fine, but the second substate seems to be confused of who its parent is:
    The visibility of the 2nd substate depends on the position of the parent state and it can be dragged partly out of its QGraphicsView.
    The substates are added with the exact same piece of code.
    I made a short video to demonstrate the behavior:
    https://www.youtube.com/watch?v=obWVBnKueJc
    I am using qt 4.8.

    Is it a general problem to have a QGraphicsView inside a QGraphicsView?
    Does anybody have a clue why this happens for the second, third etc widget?

    Thanks in advance
    veio
    Last edited by veiovis; 27th July 2014 at 14:41.

  2. #2
    Join Date
    Jul 2014
    Posts
    14
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Displaying bug with QGraphicsView in QGraphicsView

    I found out, when the 2nd substate's display is buggy:
    https://www.youtube.com/watch?v=O_GjgVHEfrw

    As long as the first substates's QGraphicsProxyWidget content is visible, the 2nd substates's QGraphicsProxyWidget is not displayed correctly,
    Last edited by veiovis; 27th July 2014 at 15:08.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Displaying bug with QGraphicsView in QGraphicsView

    That sounds like a very complicated setup.
    It is probably better to do the complete state chart inside on graphics scene, i.e. just let a state item be the parent of its sub state items and so on.

    Cheers,
    _

  4. #4
    Join Date
    Jul 2014
    Posts
    14
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Displaying bug with QGraphicsView in QGraphicsView

    Yeah, that would be a possible alternative.
    But with multiple Qgraphicsviews the management of the substates would be way easier. For example scaling the graphicsview to view all substates of a states at once is one command.
    With one big graphicsscene I would need to do that by hand.

  5. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,387
    Thanks
    247
    Thanked 687 Times in 677 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Displaying bug with QGraphicsView in QGraphicsView

    With one big graphicsscene I would need to do that by hand.
    Not necessarily. If you make custom QGraphicsObject class instances to represent each substate (i.e. containing all of the items that are now in the separate scenes used in your multiple views), then you simply set the scaling transformation for the substate graphics object you want to expand. One command, because the object will apply the same scaling to all of its children. These substate objects don't have to have any graphical representation, they can just serve as containers for the child object that do get displayed.

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

    Default Re: Displaying bug with QGraphicsView in QGraphicsView

    Quote Originally Posted by veiovis View Post
    But with multiple Qgraphicsviews the management of the substates would be way easier. For example scaling the graphicsview to view all substates of a states at once is one command.
    With one big graphicsscene I would need to do that by hand.
    It is always one command, the difference is what the subject of that command is.

    QGraphicsItem::childrenBoundingRect() returns a rectangle that encompasses all its children. You can use that to calculate the scale you need to apply to an item that contains the substate items to make all its children cover a particular area.
    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.


Similar Threads

  1. Replies: 7
    Last Post: 1st December 2011, 16:24
  2. QGraphicsView transparent over another QGraphicsView
    By evergreen in forum Qt Programming
    Replies: 0
    Last Post: 30th May 2011, 10:22
  3. QGraphicsView: Save as PNG without displaying View?
    By SixDegrees in forum Qt Programming
    Replies: 0
    Last Post: 8th October 2010, 22:56
  4. QGraphicsView not displaying QGraphicsItems
    By person in forum Qt Programming
    Replies: 7
    Last Post: 11th September 2010, 02:20
  5. Replies: 16
    Last Post: 29th March 2010, 07:05

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.