How to animate a QSplitter?
Unsolved
QtWebEngine
-
Given the following example built-in Qt Designer:
The GUI is started with the space occupied by
frame
hidden:QList<int> list = { 0, 400 }; ui.splitter->setSizes(list); ui.frame->setWindowOpacity(0);
How can I animate the
frame
while bringing her occupied space back?I tried animating it as:
// splitteranimation.h void SplitterAnimation(QWidget* widget) { int ani_speed = 1000; QPropertyAnimation* geo_ani = new QPropertyAnimation(widget, "geometry"); geo_ani->setDuration(ani_speed); geo_ani->setStartValue(widget->rect()); QRect end = QRect(widget->rect().x(), widget->rect().y(), widget->rect().width() + 200, widget->rect().height()); geo_ani->setEndValue(end); QGraphicsOpacityEffect *eff = new QGraphicsOpacityEffect(); widget->setGraphicsEffect(eff); QPropertyAnimation *op_eff = new QPropertyAnimation(eff, "opacity"); op_eff->setDuration(ani_speed); op_eff->setStartValue(0); op_eff->setEndValue(1); auto animgroup = new QParallelAnimationGroup; animgroup->addAnimation(geo_ani); animgroup->addAnimation(op_eff); animgroup->start(QAbstractAnimation::DeleteWhenStopped); }
#include "splitteranimation.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { ui.setupUi(this); QList<int> list = { 0, 400 }; ui.splitter->setSizes(list); ui.frame->setWindowOpacity(0); QShortcut *shortcut = new QShortcut(QKeySequence(Qt::Key_F2), this); connect(shortcut, &QShortcut::activated, [=] { qDebug() << "shortcut!"; SplitterAnimation(ui.frame); }); shortcut = new QShortcut(QKeySequence(Qt::Key_F3), this); connect(shortcut, &QShortcut::activated, [this] { qDebug() << "shortcut!"; SplitterAnimation(ui.splitter); }); }
When I call the geometry animation in the
frame
(F2), theframe
get resized but the space occupied by it continue 'hidden', the splitter areas didn't get resized:When i call the animation directly in the splitter (F3), the frame didn't get resized/ visible.
-
Hi and welcome to devnet,
From the top of my head, I would rather animate the handle than the widget that is in the splitter.