# carousel **Repository Path**: chen_xuyuan/carousel ## Basic Information - **Project Name**: carousel - **Description**: Qt轮播组件,用于展示界面 - **Primary Language**: C++ - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: https://pigudaxiang.cn/ - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2021-09-13 - **Last Updated**: 2024-12-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## Qt轮播组件-Carousel ### [效果](https://blog.csdn.net/t13506920069/article/details/138898526) ![image](https://img-blog.csdnimg.cn/direct/807de3104af0490bb3f2e29d1e231ab7.png) ![avatar](https://img-blog.csdnimg.cn/direct/b0298270876f4534a4a1be09eed24c24.gif) ### 如何使用 > ##### 创建实例 ```cpp #include "carousel.h" Carousel* pCarousel = new Carousel(this); ``` > ##### 设置参数 ```cpp // 设置自动播放周期 pCarousel->SetDuration(2500); // 开启自动播放 pCarousel->EnableAutoCarousel(true); // 设置界面大小 pCarousel->ResetSize(800, 400); ``` > ##### 添加展示界面 ```cpp for(int i = 0; i < 6; i++) { QLabel* pLabel = new QLabel(this); pLabel->setAlignment(Qt::AlignCenter); QPixmap pix(QString::number(i + 1) + ".jpg"); pix = pix.scaled(QSize(500, 300), Qt::KeepAspectRatio); pLabel->setPixmap(pix); pLabel->setScaledContents(true); pCarousel->Add(pLabel); } ``` > ##### 触发信号 ```cpp connect(pCarousel, &Carousel::CarouselWidgetClicked, this, [&](QWidget* widget){ // TODO: }); ```