QT 应用QSS时,没有生效??

qt1254821456 2011-12-31 01:41:51


#ifndef SHEET_H
#define SHEET_H
#include <QDialog>
class QPushButton;

class Sheet : public QDialog
{
Q_OBJECT
public:
Sheet(QWidget *parent = 0);
private:
QPushButton *pushButton ;
};
#endif // SHEET_H



#include <QApplication>
#include <QTextCodec>
#include <QPushButton>
#include <QFile>
#include <QString>

#include "sheet.h"

Sheet::Sheet(QWidget *parent)
{
pushButton = new QPushButton("sheet",this);
}

int main(int argc,char **argv)
{
QApplication app(argc,argv);

QTextCodec::setCodecForTr(QTextCodec::codecForName("GB2312"));
Sheet *sheet = new Sheet;

QFile qss("C://style.qss"); //这个是绝对路径,,,用的是XP 系统,,编译能通过,就是没有效果,,
qss.open(QFile::ReadOnly);
qApp->setStyleSheet(qss.readAll());
qss.close();

sheet->setVisible(true);
return app.exec();
}




qss:

QPushButton#pushButton
{
color : red;
}








...全文
616 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
qt1254821456 2011-12-31
  • 打赏
  • 举报
回复
不是聚焦的时候啊,,,运行的时候,,,啊,,
念茜 2011-12-31
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 qt1254821456 的回复:]

直接这样可以,,,但是效果,与网页体现的效果不一样啊,,
qApp->setStyleSheet(" QPushButton {margin:10;margin-top:30; width:125; border-style:none ;height:40;background-image: url(C://icon4.png); } QDialog {background-color: ……
[/Quote]
你所说的虚框是什么? 聚焦的时focus的框框?
qt1254821456 2011-12-31
  • 打赏
  • 举报
回复
直接这样可以,,,但是效果,与网页体现的效果不一样啊,,
qApp->setStyleSheet(" QPushButton {margin:10;margin-top:30; width:125; border-style:none ;height:40;background-image: url(C://icon4.png); } QDialog {background-color: white;}");

这个border属性,怎么设置,,按纽外面总是出现一个虚框,,,??? ??怎么回事??而border已设置为none
念茜 2011-12-31
  • 打赏
  • 举报
回复
你把style.qss copy到工程顶层目录先试试
QFile qss("style.qss");
一定可以读到,再排查错误

16,173

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧