代码拉取完成,页面将自动刷新
同步操作将从 zlqzlq/AnimateStackedWidget 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPropertyAnimation>
#include <QParallelAnimationGroup>
#include <QVBoxLayout>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
QWidget *widget = NULL;
QVBoxLayout *layout = NULL;
QLabel *label = NULL;
// widget 1
widget = new QWidget(this);
layout = new QVBoxLayout;
label = new QLabel(tr("This is widget One"), this);
label->setAlignment(Qt::AlignCenter);
layout->addWidget(label);
widget->setLayout(layout);
widget->setStyleSheet("QWidget {font-size: 24px; color: white; background-color: red}");
ui->stackedWidget->addWidget(widget);
// widget 2
widget = new QWidget(this);
layout = new QVBoxLayout;
label = new QLabel(tr("This is widget Two"), this);
label->setAlignment(Qt::AlignCenter);
layout->addWidget(label);
widget->setLayout(layout);
widget->setStyleSheet("QWidget {font-size: 24px; color: black; background-color: yellow}");
ui->stackedWidget->addWidget(widget);
// widget 3
widget = new QWidget(this);
layout = new QVBoxLayout;
label = new QLabel(tr("This is widget Three"), this);
label->setAlignment(Qt::AlignCenter);
layout->addWidget(label);
widget->setLayout(layout);
widget->setStyleSheet("QWidget {font-size: 24px; color: white; background-color: green}");
ui->stackedWidget->addWidget(widget);
// widget 4
widget = new QWidget(this);
layout = new QVBoxLayout;
label = new QLabel(tr("This is widget Four"), this);
label->setAlignment(Qt::AlignCenter);
layout->addWidget(label);
widget->setLayout(layout);
widget->setStyleSheet("QWidget {font-size: 24px; color: black; background-color: cyan}");
ui->stackedWidget->addWidget(widget);
// widget 5
widget = new QWidget(this);
layout = new QVBoxLayout;
label = new QLabel(tr("This is widget Five"), this);
label->setAlignment(Qt::AlignCenter);
layout->addWidget(label);
widget->setLayout(layout);
widget->setStyleSheet("QWidget {font-size: 24px; color: white; background-color: blue}");
ui->stackedWidget->addWidget(widget);
m_label = new QLabel(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_btnWidget1_clicked()
{
ui->stackedWidget->switchIndex(0);
}
void MainWindow::on_btnWidget2_clicked()
{
ui->stackedWidget->switchIndex(1);
}
void MainWindow::on_btnWidget3_clicked()
{
ui->stackedWidget->switchIndex(2);
}
void MainWindow::on_btnWidget4_clicked()
{
ui->stackedWidget->switchIndex(3);
}
void MainWindow::on_btnWidget5_clicked()
{
ui->stackedWidget->switchIndex(4);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。