Upgrade QGraphicsTextItem (and friends) to QGraphicsWidget?



  • 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?



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



  • 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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.