VSCode导入QSS文件

VSCode对Qml编程非常友好,不仅有优秀的代码提示,而且还有好用的交互功能。

在main.cpp中引入这个qss文件

cpp 复制代码
#include "qttest3.h"
#include <QApplication>
#include <QFile>
#include <fstream>
#include <stdio.h>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QPushButton qPushButton;
    QFile styleFile("../view/qt.qss"); // 从资源文件中加载QSS文件
    styleFile.open(QFile::ReadOnly);
    QString styleSheet = QLatin1String(styleFile.readAll());
    qApp->setStyleSheet(styleSheet);
    qttest3 w;
    w.show();
    return a.exec();
}

运行代码,通过qss可以做到和css一样的酷炫效果。

相关推荐
一律清风1 小时前
【Opencv】canny边缘检测提取中心坐标
c++·opencv
a东方青5 小时前
蓝桥杯 2024 C++国 B最小字符串
c++·职场和发展·蓝桥杯
mahuifa5 小时前
(7)python开发经验
python·qt·pyside6·开发经验
XiaoyaoCarter6 小时前
每日一道leetcode
c++·算法·leetcode·职场和发展·二分查找·深度优先·前缀树
galaxy_strive6 小时前
qtc++ qdebug日志生成
开发语言·c++·qt
TNTLWT6 小时前
Qt功能区:简介与安装
开发语言·qt
Darkwanderor7 小时前
c++STL-list的模拟实现
c++·list
Humbunklung7 小时前
Visual Studio 2022 中添加“高级保存选项”及解决编码问题
前端·c++·webview·visual studio
小乌龟不会飞8 小时前
gflags 安装及使用
c++·mfc·gflags 库
June`8 小时前
专题二:二叉树的深度搜索(二叉树剪枝)
c++·算法·深度优先·剪枝