为啥要写一个模版了,原因就是有到多需要用到了,哈哈哈哈。

是这样滴,一套模拟器上面会有N多个设备,这些设备相互联合又相互独立工作。我呢,需要给每个设备多写一个配置工具,最后需要把这些工具整理成一套系统的配置工具。所以,每个配置工具除了内容不同,界面风格应该相同的,就有这个模版了。

 

万恶的CSDN穿图片的大小还是不可以太大,只能贴截图了。

Qt-写一个模版出来_QT

第一个是系统的启动动画,这个有点大 ,没法预览,制作方式

1. 网上找好看的AE特效模版

2. 把自己的内容替换上去

3. 导出视屏

4. 用PR转成GIF

这样就可了

至于真么加载这个动画,看代码

#include "mainwindow.h"
#include <QApplication>
#include <QSplashScreen>
#include <QPixmap>
#include <QLabel>
#include <QMovie>
#include <QThread>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QPixmap pixmap("./images/login.gif");
    QSplashScreen splash(pixmap);
    QMovie *movie = new QMovie("./images/login.gif");
    QLabel *label = new QLabel(&splash);
    label->setMovie(movie);
    movie->start();
    splash.show();
    for(int i = 0;i<11000;i+=movie->speed())
    {
        QCoreApplication::processEvents();
        QThread::usleep(500*movie->speed());
    }

    a.setStyleSheet("QLineEdit {border-radius: 4px;height: 25px;border: 1px solid rgb(100, 100, 100);background: rgb(72, 72, 73);}"
                    "QLineEdit:enabled {color: rgb(175, 175, 175);}"
                    "QLineEdit:enabled:hover, QLineEdit:enabled:focus {color: rgb(230, 230, 230);}"
                    "QLineEdit:!enabled {color: rgb(155, 155, 155);}"

                    "QPushButton{border-radius: 4px;border: none;width: 75px;height: 25px;}"
                    "QPushButton:enabled {background: rgb(68, 69, 73);color: white;}"
                    "QPushButton:!enabled {background: rgb(100, 100, 100);color: rgb(200, 200, 200);}"
                    "QPushButton:enabled:hover{background: rgb(85, 85, 85);}"
                    "QPushButton:enabled:pressed{background: rgb(80, 80, 80);}"
                    //关闭按钮样式
                    "QPushButton#pushButton_close{border-radius: 0px;background: rgb(0,0,0,0,);border-image:url(./images/close_n.png);}"
                    "QPushButton::hover#pushButton_close{border-image:url(./images/close_p.png);}"
                    "QPushButton::pressed #pushButton_close{border-image:url(./images/close_n.png);}"
                    //最小化按钮样式
                    "QPushButton#pushButton_min{border-radius: 0px;background: rgb(0,0,0,0,);border-image:url(./images/min_n.png);}"
                    "QPushButton::hover#pushButton_min{border-image:url(./images/min_p.png);}"
                    "QPushButton::pressed #pushButton_min{border-image:url(./images/min_n.png);}"
                    //关于按钮样式
                    "QPushButton#pushButton_about{border-radius: 0px;background: rgb(0,0,0,0,);border-image:url(./images/about_n.png);}"
                    "QPushButton::hover#pushButton_about{border-image:url(./images/about_p.png);}"
                    "QPushButton::pressed #pushButton_about{border-image:url(./images/about_n.png);}"

                    "QLabel {color: rgb(175, 175, 175);}"

                    );


    MainWindow w;
    w.show();
    splash.finish(&w);
    return a.exec();
}

中间有部分是样式表,自动忽略就好

Qt-写一个模版出来_引导动画_02

上面的这个图画就是我的基本模版了,

做了一下工作

1. 隐藏了原有的标题栏

2. 左上角增加了图标和标题

3. 右上角增加了关于、最小化和关闭按钮

4. 限制了鼠标点击点击区域

上下的看代码

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QNetworkDatagram>
#include <QMessageBox>
#include <windows.h>
#include <QDebug>
/*
 * 设定标题栏宽度
 * 后面鼠标事件会用到
 */
const int TITLE_HEIGHT = 30;
/*
 * 构造函数
 */
MainWindow::MainWindow(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    this->setWindowFlag(Qt::FramelessWindowHint);
    this->setWindowIcon(QIcon("./images/logo.ico"));
    ui->pushButton_about->setToolTip("关于我们");
    ui->pushButton_close->setToolTip("关闭");
    ui->pushButton_min->setToolTip("最小化");
    ui->label_ICON->setStyleSheet("QLabel{border-image:url(./images/logo.ico);}");
    ui->label_title->setStyleSheet("QLabel{color: rgb(255, 255, 255);border:0px;}");
    ui->label_title->setText("M1J1DNT701");
}
/*
 * 析构函数
 */
MainWindow::~MainWindow()
{
    delete ui;
}
/*
 * 绘制背景
 */
void MainWindow::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);
    QPainter painter_back(this);
    painter_back.drawPixmap(0,0,this->width(),this->height(),QPixmap("./images/mainback.png"));
}
//存放当前鼠标位置函数
static QPoint last(0,0);
/*
 * 鼠标按下函数
 */
void MainWindow::mousePressEvent(QMouseEvent *event)
{
    if(event->y()< TITLE_HEIGHT)
    {
        last = event->globalPos();
    }
}
/*
 * 鼠标移动函数
 */
void MainWindow::mouseMoveEvent(QMouseEvent *event)
{
    if(event->y() < TITLE_HEIGHT)
    {
        int dx = event->globalX() - last.x();
        int dy = event->globalY() - last.y();
        last = event->globalPos();
        this->move(x()+dx,y()+dy);
    }
}
/*
 * 鼠标释放函数
 */
void MainWindow::mouseReleaseEvent(QMouseEvent *event)
{
    if(event->y() < TITLE_HEIGHT)
    {
        int dx = event->globalX() - last.x();
        int dy = event->globalY() - last.y();
        this->move(x()+dx,y()+dy);
    }
}


/*
 * 关闭按钮槽函数
 */
void MainWindow::on_pushButton_close_clicked()
{
    this->close();
}

好了,暂时就这些