PDA

View Full Version : how to apply stylesheet defined in .qss file to qt application



namita
13th March 2008, 09:30
Hi,

Can anyone pls tell me how to apply external stylesheet defined in a .qss file to a qt application? I'm using qt4.3

I dont want to use command line switch "-stylesheet".


Thanks in advance,
Namita

wysota
13th March 2008, 09:35
QApplication app(...);
QFile qss("stylesheet.qss");
qss.open(QFile::ReadOnly);
app.setStyleSheet(qss.readAll());
qss.close();

namita
17th March 2008, 07:06
Hi,

Thanks a lot...
Now i'm able to apply external stylesheet to the qt application.


Regards,
Namita

phillip_Qt
17th March 2008, 07:09
Hi,

Thanks a lot...
Now i'm able to apply external stylesheet to the qt application.


Regards,
Namita

Hi. Im also using qss file. Are u adding Q_INIT_RESOURCES in ur main(), inorder to initialise qss?

Thanx.

wysota
17th March 2008, 07:25
QSS and Q_INIT_RESOURCES have nothing to do with each other.

phillip_Qt
17th March 2008, 07:33
QSS and Q_INIT_RESOURCES have nothing to do with each other.

As far my understand I think qss(qt Style sheet) is also a resources and Q_INIT_RESOURCES is required to initialise all resources. So i asked this. I also posted this inforum http://www.qtcentre.org/forum/f-qt-programming-2/t-initialising-resource-12508.html But i didnt get any reply. So i asked this.:(

wysota
17th March 2008, 12:08
As far my understand I think qss(qt Style sheet) is also a resources
That's not true.

and Q_INIT_RESOURCES is required to initialise all resources.
That's not true as well.

"Qt resources" is a virtual filesystem, nothing more, nothing less. Stylesheets have nothing to do with files and in this particular case the stylesheet is loaded from an external and real file.

Q_INIT_RESOURCES is only needed if you want to initialize resources that are embedded int a static library on some of the platforms. It' required to link them to the filesystem already existing in the application.

phillip_Qt
17th March 2008, 12:46
That's not true.

That's not true as well.

"Qt resources" is a virtual filesystem, nothing more, nothing less. Stylesheets have nothing to do with files and in this particular case the stylesheet is loaded from an external and real file.

Q_INIT_RESOURCES is only needed if you want to initialize resources that are embedded int a static library on some of the platforms. It' required to link them to the filesystem already existing in the application.

Thank you very much
But i ve a doubt, can i use Q_INIT_RESOURCE macro in a dll.?

wysota
17th March 2008, 14:04
Do you need the macro? Yes, you can use it, but you probably don't have to.