Qt - Netease cloud music interface realizes - 9 photo wall function

Recently, I bought the car, but I'm not as happy as I thought. I really want to buy consumables.

I have written this topic. I originally wanted to hone myself, but I may have to deal with GG. It's boring.

Let's take a look at the renderings first

This photo wall is almost a thing, but I personally think you need to rewrite a control's mouse to enter the event, that's OK. I'm lazy, and I won't write here. You can try what you are interested in.

There is no technical content here. Code up.

#include "picturewallform.h"
#include "ui_picturewallform.h"



int static picture_index = 2;       //Current picture index value
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);
    }
}

Interested, can and I want source code.

Posted on Fri, 31 Jan 2020 22:04:55 -0500 by shan111