QPropertyAnimation can't used to Qtabwidget
Unsolved
General and Desktop
-
I want to hide the Qtabwidget
So I used QPropertyAnimation to make Qtabwidget's width is 0 in 400ms
but the tabwidget will rebound
the tabwidget's sizepolicy is expanding
other widget is okay,like Qframe,buton.....
I don't know how to do that//frame_2 has the tabwidget QPropertyAnimation *animation= new QPropertyAnimation(ui->frame_2,"geometry"); animation->setDuration(400); animation->setStartValue(ui->frame_2->geometry()); if(expanded){ animation->setEndValue(QRect(0,0, 0, ui->frame_2->height())); } else { animation->setEndValue(QRect(0,0, 500, ui->frame_2->height())); }
-
@hezf
If parent widget changed(like size), other widgets will re-arranged also.
You should remove layout of QFrame and then use hide()/show() for QFrame.Ex)
[...] // set up animation, frame has the QTabWidget animation= new QPropertyAnimation(ui->frame, "geometry"); animation->setDuration(400); animation->setStartValue(ui->frame->geometry()); animation->setEndValue(QRect(ui->frame->x(), ui->frame->y(), 0, ui->frame->height())); connect(animation, &QPropertyAnimation::finished, [&]{ if (animation->direction() == QPropertyAnimation::Forward) { ui->frame->hide(); animation->setDirection(QPropertyAnimation::Backward); } else animation->setDirection(QPropertyAnimation::Forward); }); [...] // start animation if (animation->direction() == QPropertyAnimation::Backward) ui->frame->show(); animation->start();
-
@Devopia53
Hi,
Can you send me the project?
hezf@boltit.cn