代码拉取完成,页面将自动刷新
同步操作将从 zlqzlq/AnimateStackedWidget 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "animatestackedwidget.h"
#include <QPropertyAnimation>
#include <QParallelAnimationGroup>
#include <QPixmap>
AnimateStackedWidget::AnimateStackedWidget(QWidget *parent) : QStackedWidget(parent)
{
m_label = new QLabel(this);
}
void AnimateStackedWidget::switchIndex(int newIdx)
{
int oldIdx = currentIndex();
if (oldIdx == newIdx || newIdx < 0 || newIdx >= count())
{
return;
}
int w = this->width();
int h = this->height();
QPixmap pixmap = QPixmap::grabWindow(this->winId());
m_label->setPixmap(pixmap);
m_label->setGeometry(0, 0, w, h);
m_label->show();
setCurrentIndex(newIdx);
QPropertyAnimation *animation1 = new QPropertyAnimation(m_label, "pos");
QPropertyAnimation *animation2 = new QPropertyAnimation(currentWidget(), "pos");
animation1->setDuration(500);
animation2->setDuration(500);
animation1->setEasingCurve(QEasingCurve::OutCubic);
animation2->setEasingCurve(QEasingCurve::OutCubic);
if (oldIdx < newIdx) //
{
animation1->setStartValue(QPoint(0, 0));
animation1->setEndValue(QPoint(0 - w, 0));
animation2->setStartValue(QPoint(w, 0));
animation2->setEndValue(QPoint(0, 0));
}
else // һ
{
animation1->setStartValue(QPoint(0, 0));
animation1->setEndValue(QPoint(w, 0));
animation2->setStartValue(QPoint(0 - w, 0));
animation2->setEndValue(QPoint(0, 0));
}
QParallelAnimationGroup *group = new QParallelAnimationGroup;
group->addAnimation(animation1);
group->addAnimation(animation2);
group->start(QAbstractAnimation::DeleteWhenStopped);
connect(group, SIGNAL(finished()), m_label, SLOT(hide()));
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。