Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Combining QGraphicsSvgItem with QGraphicsLayoutItem
Forum Update on Monday, May 27th 2025

Combining QGraphicsSvgItem with QGraphicsLayoutItem

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 4.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Palmik
    wrote on last edited by
    #1

    Hi, I'm working on a small project (inspired by "this(Layoutitem)":http://qt.gitorious.org/qt/qt/blobs/master/examples/graphicsview/basicgraphicslayouts/layoutitem.cpp) where I am trying to combine the powers of QGraphicsSvgItem and QGraphicsLayoutItem.
    You can find the project "here (QGraphicsSvgLayoutItem)":http://gitorious.org/qgraphicssvglayoutitem/qgraphicssvglayoutitem/trees/master with a test case, it's ready to compile.

    The problems I currently have are:

    • Rotation behaves funny -- the item is rotated, but when you resize the window it behaves in a weird way (it's scaled in wrong directions)
    • When I set a parent item to my item, it does not seem to be displayed at all.

    I would appreciate all hints and help :)

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jorj
      wrote on last edited by
      #2

      does the layout work if you dont use an svg item? try just an ellipse item or something else.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Palmik
        wrote on last edited by
        #3

        Hi Jorj, thanks for input! I have subclassed QGraphicsLayoutItem together with QGraphicsRectItem (because I can not simply put the QGraphicsItem into QGraphicsLayout) and even thought the code is now much shorter and straightforward, the same problem is still present. But it should be easier to hunt down the problem now with the simple rect item.

        "Here ((Compilable testcase)":http://filebeam.com/620ef986954780b93a675fee1a865571 (or "here (Compilable testcase)":http://palmik.net/files/QGraphicsRectLayoutItem_pack.rar) is the whole compilable source with testcase and "here on codepad is(Codepad sample)":http://codepad.org/VqYnWtoY just the QGraphicsRectLayoutItem implementation.

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Palmik
          wrote on last edited by
          #4

          Ok, when I was having a batch I realized that the reason for that weir behavior if fairly simple... it's because it always draws the painting of size of the bounding rect, which forks fine (when the rotation() % 180 == 0) but otherwise it does not work, since the bounding rect in my implementation is the same for all items in the layout.

          Now to the solution -- there are at least two ways I can think of to solve this problem

          Shrink the item when rotated (possibly by tinkering with the paint() reimplemantion) so that the geometry() would be same for all the cells of layout but will not overlap other cells.

          Expand the bounding rect when rotated (possibly by tinkering with geometry() reimplementation) so that the item will be of the same size as if it would be unrotated but will not overlap other cells.

          I will probably implement both at some point... Now I just have to figure out the math to calculate the sizes properly. :)

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved