Results 1 to 5 of 5

Thread: Group/children positioning within Qt Graphics Framework

  1. #1
    Join Date
    Feb 2006
    Location
    US
    Posts
    173
    Thanks
    16
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Group/children positioning within Qt Graphics Framework

    Hello,

    I'm having 3 (related) issues with grouping within the Qt Graphics Framework. These occur with either the QGraphicsItemGroup::addToGroup() or QGraphicsItem::setParentItem() grouping methods.

    1) When you create a group within Qt, its initial position as reported by the pos() method is (0,0) independent of its child items' bounding rectangle. The group (when created) could be contained within the rectangle x=100, y=100, w=10, h=10 and it still has position of (0,0). This is not intuitive to the user; (0,0) isn't even within the bounding rectangle. The pos() should be the upper left (or center) of the bounding rectangle.

    2) Rotating the group is relative to (0,0) -- not relative to the group's bounding rectangle.

    3) There is no convenient way to get/set the actual scene-relative position and rotation for a child of a group. Moving the group has no effect on the position reported by the child pos() method. This is further complicated by the fact that QGraphicsItem uses two affine transformation systems: one for the setPos(), setRotation(), and setScale() methods and another for the setTransform() method. Coming from a gaming & simulation background, this is imho a completely non-standard way of handling transformations. This took my by surprise as most every other aspect of Qt employs industry common best practices.

    Thanks,
    Ben

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

    Default Re: Group/children positioning within Qt Graphics Framework

    Hmm, there doesn't seem to be any question in this posting, the closest thing seems to be the part about getting an item's position in scene coordinates.

    I think that should be possible by mapping the item's pos() using the same item's mapToScene().

    Cheers,
    _

  3. #3
    Join Date
    Feb 2006
    Location
    US
    Posts
    173
    Thanks
    16
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Group/children positioning within Qt Graphics Framework

    Have you ever used software that provides the function above? My point was that it is non-standard behavior and I need help providing the features. I've restated the issues as questions below.

    PowerPoint, Visio, et al all
    1) provide to the user a group's position as relative to it's bounding rectangle (not zero)
    2) rotate about the group bounding rectangle's center (not about center of scene)
    3) provide the scene position of the child of the group (not independent of the group)

    How are the original common features (mentioned above) normally provided to the user for Qt graphical applications such as PPT, Visio, etc? I'm developing an editor and need to implement said features. Why would Qt groups have a position of zero at creation that's independent of the bounding items? Why would rotating a Qt group rotate about the scene origin rather than the bounding region's center?

    Additionally, how do you get the scene relative rotation for an element within a group that has been rotated and moved? I don't see a mapToScene() type API for rotation. I was able to compute it implementing my own 2D affine transformations, but it wasn't straight forward.

    Finally, why would ungrouping a moved/rotated group of items produce the result of the grouped items in the position/rotation before they were grouped, moved, and rotated? It's not expected behavior. Is there something in Qt that readily provides this? Am I missing something?

    Besides the issues above (not to be missed), but the mapToScene() position isn't reporting a correct value when the group has been moved and rotated and the group's children have been subsequently moved and rotated after grouping.
    In the image below, the red graphic (numbered 1) is indicating a position from mapToScene of (-15, 25) rather than the correct value of (-10, 10).
    groupChildPos.jpg
    Last edited by brcain; 2nd July 2014 at 18:22.

  4. #4
    Join Date
    Feb 2006
    Location
    US
    Posts
    173
    Thanks
    16
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Group/children positioning within Qt Graphics Framework

    anda_skoa (or wysota Master of all things Qt), can I get a more substantive response?

    It may be that Qt grouping is designed differently than PowerPoint, Visio, OpenOffice Impress, and every other tool I've used with grouping functionality.
    Or, it may be that I'm missing something obvious because I'm too obtuse.

    Nonetheless, would you provide a hint of direction and address the 3+ aforementioned issues?

    Thanks much,
    Ben

  5. #5
    Join Date
    Feb 2006
    Location
    US
    Posts
    173
    Thanks
    16
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Group/children positioning within Qt Graphics Framework

    After wrestling with Qt's grouping implementation for about 4 days, I ended up refactoring the Qt graphics framework grouping functionality to provide the common features described above.
    It's working great; a bonus ... it simplified implementation of the undo/redo operations.

Similar Threads

  1. Graphics framework + Qt3D problem
    By RenderMan in forum Qt Programming
    Replies: 0
    Last Post: 18th February 2010, 20:26
  2. Problem about Graphics View Framework
    By FinderCheng in forum Qt Programming
    Replies: 5
    Last Post: 3rd November 2009, 08:16
  3. Problem with Graphics View Framework
    By Disperato in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2009, 20:44
  4. Issues with the Graphics View Framework
    By lni in forum Qt Programming
    Replies: 8
    Last Post: 26th April 2009, 14:13
  5. about the contextMenuEvent in graphics view framework
    By bingoking in forum Qt Programming
    Replies: 1
    Last Post: 21st April 2009, 06:04

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.