wumu
2024-11-01 71c27f9ead97e52e50a59495c6955756e21004cf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "clientmainwindow.h"
#include <QApplication>
#include <QStandardPaths>
#include <QDebug>
#pragma execution_character_set("utf-8")
 
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    ClientMainWindow w;
    //w.setStyleSheet("background-color:#FFC7F0");
    // 蓝色渐变
    //w.setStyleSheet("background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #7bbfea,stop:0.5 #afdfe4 ,stop:1 #7bbfea)");
 
    // 绿色渐变
    //w.setStyleSheet("background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #a3cf62,stop:0.5 #bed742 ,stop:1 #a3cf62)");
 
 
//    QLinearGradient gradient(0, 0, 1, 1); // 创建线性渐变对象
//    gradient.setColorAt(0.0, QColor(255, 0, 0)); // 设置起始颜色
//    gradient.setColorAt(1.0, QColor(0, 255, 0)); // 设置结束颜色
 
//    // 将渐变效果应用到 QWidget 上
//    QPalette palette;
//    palette.setBrush(QPalette::Background,gradient);
//    w.setBackgroundRole(QPalette::Highlight);
//    w.setPalette(palette);
//    w.setAutoFillBackground(true);
 
 
    w.show();
 
    // 处理快捷方式到桌面
 
    QString strAppPath = QApplication::applicationFilePath();
    QString strDesktopLink = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/";
    strDesktopLink += "internal_system.lnk";
    qDebug()<<"桌面路径:"<<strDesktopLink;
    qDebug()<<"app:"<<QApplication::applicationFilePath();
 
    QFile desk(strDesktopLink);
 
    QFile fApp(strAppPath);
    if(!desk.exists()){
        fApp.link(strDesktopLink);
        qDebug()<<"添加快捷方式成功";
    }else{
        qDebug()<<"快捷方式已存在,不添加";
    }
 
 
//    //建立开始菜单快捷方式
//    QString strMenuLink = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation) + "/";
//    strMenuLink += "notepad/";
//    QDir pathDir;
//    pathDir.mkpath(strMenuLink);
//    strMenuLink += "notepad.lnk";
//    fApp.link(strMenuLink);
 
    return a.exec();
}