QGraphicsWidget sizing and expand direction in QGraphicsLinearLayout



  • I had a QGraphicsWidget with QGraphicsLinearLayout assigned to it. The layout contains many QGraphicsWidget items. I want to re-size each individual QGraphicWidget by dragging either its left edge or its right edge.

    -When I drag the right edge, I want QGraphicsWidget expand its size to the right and shift other widgets (from the right side of current adjusting widget). This can be achieved easily because of the default behavior of QGraphicsLinearLayout.

    -When I drag the left edge, I want QGraphicsWidget expand its size to the left and shift other widgets (from the left side of current adjusting widget).

    Illustration diagram


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    That sounds rather like a QSplitter behavior, one between each widget



  • Hi SGaist,
    Does GraphicsView / GraphicsScene have that built-in behavior?
    Think I can subclass QGraphicsLayout .
    In the worst case , i have to manually keep track of item's coordinates by myself.


  • Lifetime Qt Champion

    AFAIK, no

    Wouldn't using QSplitter and only one QGraphicsWidget with be simpler ?



  • Thanks for response.
    Can you please go a bit more detail?
    How would you add QSplitter (QWidget based) into QGraphicsLinearLayout?


  • Lifetime Qt Champion

    No, my idea was to build your set of resizable widgets with QSplitter and then add that QSplitter to your scene