Important: Please read the Qt Code of Conduct -

QPropertyAnimation for widgets in layout

  • Hi all,

    I have problem with animating widgets height in QVBoxLayout.
    Widgets are QFrame's stacked one above another arranged with QVBoxLayout inside QScrollAreaWidget
    When I start QPropertyAnimation for geometry of the first widget it changes it height but other items in layout don't change their position. In other words first expanded widget is obsured by the next QFrame and what is more when I resize main window all widgets rearrange their heights as the animation never took place

    Is it possible to animate widget height in layout ? so the other items follow the animation?

    When I was doing the same in QGraphicsView (changing height of QGraphicsRectItem) next item was child of the first and always positioned e.g 20px below first item, so when I changed the first item height other items moved automatically. Is it possible with widgets ?

    Best Regards

  • Lifetime Qt Champion

    The layout will try to arrange them so
    animating the geometry at the same time
    might not produce the effect you are after.

    Animating maximum Height might work better as layout try to respect that.

  • Hi,

    Thanks for the tip,
    I'm using now valueChanged SIGNAL from QPropertyAnimation for setMinimumSize for widget and it works as You said.
    I also need some widgets to be visible after QFrame height is increased so I'm doing some tests.
    Basically I want to be sure which way should I go, classic QWidgets or QGraphicsItems where I have the full control.
    Will post my findings.

  • Hi,

    It works with QLayout and animated widgets. (Qt 5.7)

    setSizeConstraint(QLayout::SetFixedSize) for the layout is crucial, otherwise items move slightly when animation is running.

    Best Regards

Log in to reply