PDA

View Full Version : Change Qt theme while running



Macok
12th February 2009, 20:04
I saw an application which permit user to change Qt theme of this application while it's running.
I know that it's possible to change Qt theme for whole system, but how to do it for one application only?

If you don't understand what i mean, here's screen from "Kadu":
http://img23.imageshack.us/img23/2535/ss1wg0.png

talk2amulya
12th February 2009, 20:20
by using setStyleSheet() ?

jpn
12th February 2009, 20:25
QApplication::setStyle()

Macok
12th February 2009, 20:26
Thanks, and one more question:
How to get list of styles that are available in system?

jpn
12th February 2009, 20:28
See QStyleFactory::keys().

Macok
12th February 2009, 20:46
Thanks for the answer, but why this code doesn't work?
QStyle *style=QStyleFactory::create("motif");
setStyle(style);I added it to the mainwindow constructor, but application theme is still the same.

@Edit
Ok, I had to write
QApplication::setStyle instead of
setStyle

jpn
12th February 2009, 20:53
Oh, QWidget::setStyle() seems to be somehow broken at least in Qt 4.5.0-beta1. Yeah, QApplication::setStyle() still works.

Macok
12th February 2009, 20:57
Ok, thanks jpn!