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. Upgrade QGraphicsTextItem (and friends) to QGraphicsWidget?
Qt 6.11 is out! See what's new in the release blog

Upgrade QGraphicsTextItem (and friends) to QGraphicsWidget?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.8k Views 1 Watching
  • 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.
  • A Offline
    A Offline
    Asperamanca
    wrote on last edited by
    #1

    I'd like to use some of the ready-to-use QGraphicsItem classes, like QGraphicsTextItem, QGraphicsPixmapItem,...

    However, I want to use layouts, so I need QGraphicsWidgets.

    The only way I could come up with would be to create a class that derives from QObject, QGraphicsTextItem (or another) and QGraphicsLayoutItem, and then implement those methods that are implemented in QGraphicsObject or QGraphicsWidget, and missing in QGraphicsTextItem.

    Sounds a bit tricky. Any better idea?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MaQzma
      wrote on last edited by
      #2

      Well, you could use Adapter design pattern, but I am not sure.

      Mario.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Asperamanca
        wrote on last edited by
        #3

        My best idea right now is to use a composition: A QGraphicsWidget containing the item I want. The tricky part is that one essential change notification (boundingRect changes) is missing, which makes things kinda awkward.

        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