Qt-网易云音乐界面实现-9 照片墙功能
最近车也买了,不过倒是没有想象的那么开心,车真的是想消耗品啊。
写这个专题了,本来是想好好的磨练一下自己,不过可能要在在理就GG了。腻味了。
还是先看下效果图吧
这个照片墙还差点东西,不过我个人认为需要重写一个控件的鼠标进入事件,就可以了,懒了,这里就不写了。感兴趣的可以试试看。
这里没有技术含量。上代码吧
#include "picturewallform.h" #include "ui_picturewallform.h" int static picture_index = 2; //当前图片索引值 PictureWallForm::PictureWallForm(QWidget *parent) : QWidget(parent), ui(new Ui::PictureWallForm) { ui->setupUi(this); QString qss_1 = QString("QLabel{border-image:url(./images/picturewall/00%1.png);}").arg(picture_index); QString qss_2 = QString("QLabel{border-image:url(./images/picturewall/00%1.png);}").arg(picture_index-1); QString qss_3 = QString("QLabel{border-image:url(./images/picturewall/00%1.png);}").arg(picture_index+1); ui->label_main->setStyleSheet(qss_1); ui->label_main_l->setStyleSheet(qss_2); ui->label_main_r->setStyleSheet(qss_3); } PictureWallForm::~PictureWallForm() { delete ui; } void PictureWallForm::on_pushButton_plus_clicked() { picture_index++; if(picture_index==8) { QString qss_1 = QString("QLabel{border-image:url(./images/picturewall/00%1.png);}").arg(picture_index); QString qss_2 = QString("QLabel{border-image:url(./images/picturewall/00%1.png);}").arg(picture_index-1); QString qss_3 = QString("QLabel{border-image:url(./images/picturewall/00%1.png);}").arg("1"); ui->label_main->setStyleSheet(qss_1); ui->label_main_l->setStyleSheet(qss_2); ui->label_main_r->setStyleSheet(qss_3); picture_index = 0; } else { QString qss_1 = QString("QLabel{border-image:url(./images/picturewall/00%1.png);}").arg(picture_index); QString qss_2 = QString("QLabel{border-image:url(./images/picturewall/00%1.png);}").arg(picture_index-1); QString qss_3 = QString("QLabel{border-image:url(./images/picturewall/00%1.png);}").arg(picture_index+1); ui->label_main->setStyleSheet(qss_1); ui->label_main_l->setStyleSheet(qss_2); ui->label_main_r->setStyleSheet(qss_3); } } void PictureWallForm::on_pushButton_subtract_clicked() { picture_index--; if(picture_index==1) { QString qss_1 = QString("QLabel{border-image:url(./images/picturewall/00%1.png);}").arg(picture_index); QString qss_2 = QString("QLabel{border-image:url(./images/picturewall/00%1.png);}").arg("8"); QString qss_3 = QString("QLabel{border-image:url(./images/picturewall/00%1.png);}").arg(picture_index+1); ui->label_main->setStyleSheet(qss_1); ui->label_main_l->setStyleSheet(qss_2); ui->label_main_r->setStyleSheet(qss_3); picture_index = 8; } else { QString qss_1 = QString("QLabel{border-image:url(./images/picturewall/00%1.png);}").arg(picture_index); QString qss_2 = QString("QLabel{border-image:url(./images/picturewall/00%1.png);}").arg(picture_index-1); QString qss_3 = QString("QLabel{border-image:url(./images/picturewall/00%1.png);}").arg(picture_index+1); ui->label_main->setStyleSheet(qss_1); ui->label_main_l->setStyleSheet(qss_2); ui->label_main_r->setStyleSheet(qss_3); } }
有感兴趣的,可以和我要源码。