高级轮播图,实现椭圆轨迹的无限滚动。
实现了一个基于椭圆的无限轮播图组件Daen_no_Kado。主要功能包括:1) 通过椭圆轨迹实现图片的无限循环展示;2) 支持左右按钮点击、鼠标拖动和滚轮操作切换图片;3) 包含动画效果和进度条显示;4) 图片会根据椭圆路径进行3D旋转和缩放变换。组件使用Qt框架开发,通过QPainter绘制椭圆路径下的图片展示区域,并利用QPropertyAnimation实现按钮动画效果。图片切换时采用平滑过渡,支持自动轮播和手动交互控制。

#include "daen_no_kado.h"
Daen_no_Kado::Daen_no_Kado(QWidget *parent)
: QWidget{parent}
{
this->resize(1200, 606);
recta = QRect(0, 0, 1200, 606);
QPalette pal(this->palette());
pal.setColor(QPalette::Window, QColor(243, 246, 253));
this->setPalette(pal);
button = new Latticed_Circle_Button(this);
button2 = new Latticed_Circle_Button(this);
button->Shikisai_no_joutai = true;
connect(button, &Latticed_Circle_Button::Latticed_Circle_Click_Signal, this, &Daen_no_Kado::Move_Left);
connect(button2, &Latticed_Circle_Button::Latticed_Circle_Click_Signal, this, &Daen_no_Kado::Move_Right);
this->Get_Image();
this->Kiso_Deta_Kouchiku();
this->Gazou_wo_nabebae_ru();
connect(&timerA, &QTimer::timeout, this, &Daen_no_Kado::koushin_suru);
timerA.setInterval(16);
connect(&timerB, &QTimer::timeout, this, &Daen_no_Kado::Progress_Bar_Data_Update);
timerB.setInterval(16);
timerB.start();
this->animations();
}
void Daen_no_Kado::animations()
{
animation = new QPropertyAnimation(this->button, "geometry");
animation->setDuration(300);
animation->setStartValue(this->button->geometry());
animation->setEndValue(QRect(this->button->pos().x() - zoom_rate / 2, this->button->pos().y() - zoom_rate / 2, button->width() + zoom_rate, button->height() + zoom_rate));
animation->setEasingCurve(QEasingCurve::Linear);
animation2 = new QPropertyAnimation(this->button2, "geometry");
animation2->setDuration(300);
animation2->setStartValue(this->button2->geometry());
animation2->setEndValue(QRect(this->button2->pos().x() - zoom_rate / 2, this->button2->pos().y() - zoom_rate / 2, button2->width() + zoom_rate, button2->height() + zoom_rate));
animation2->setEasingCurve(QEasingCurve::Linear);
connect(button, &Latticed_Circle_Button::execute_animation_signal, this, [this](Latticed_Circle_Button::AnimationState state)
{
if (state == Latticed_Circle_Button::Execute)
{
animation->setDirection(QAbstractAnimation::Forward);
animation->start();
}
else if (state == Latticed_Circle_Button::Restore)
{
animation->setDirection(QAbstractAnimation::Backward);
animation->start();
}
});
connect(button2, &Latticed_Circle_Button::execute_animation_signal, this, [this](Latticed_Circle_Button::AnimationState state)
{
if (state == Latticed_Circle_Button::Execute)
{
animation2->setDirection(QAbstractAnimation::Forward);
animation2->start();
}
else if (state == Latticed_Circle_Button::Restore)
{
animation2->setDirection(QAbstractAnimation::Backward);
animation2->start();
}
});
animation3 = new QPropertyAnimation(this

最低0.47元/天 解锁文章
3330

被折叠的 条评论
为什么被折叠?



