Results 1 to 8 of 8

Thread: Change Qt theme while running

  1. #1
    Join Date
    Jan 2009
    Posts
    51
    Thanks
    28
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Change Qt theme while running

    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":

  2. #2
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Change Qt theme while running

    by using setStyleSheet() ?

  3. The following user says thank you to talk2amulya for this useful post:

    Macok (12th February 2009)

  4. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Change Qt theme while running

    J-P Nurmi

  5. #4
    Join Date
    Jan 2009
    Posts
    51
    Thanks
    28
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Change Qt theme while running

    Thanks, and one more question:
    How to get list of styles that are available in system?

  6. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Change Qt theme while running

    J-P Nurmi

  7. The following user says thank you to jpn for this useful post:

    Macok (12th February 2009)

  8. #6
    Join Date
    Jan 2009
    Posts
    51
    Thanks
    28
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Change Qt theme while running

    Thanks for the answer, but why this code doesn't work?
    Qt Code:
    1. QStyle *style=QStyleFactory::create("motif");
    2. setStyle(style);
    To copy to clipboard, switch view to plain text mode 
    I added it to the mainwindow constructor, but application theme is still the same.

    @Edit
    Ok, I had to write
    Qt Code:
    1. QApplication::setStyle
    To copy to clipboard, switch view to plain text mode 
    instead of
    Qt Code:
    1. setStyle
    To copy to clipboard, switch view to plain text mode 
    Last edited by Macok; 12th February 2009 at 19:57.

  9. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Change Qt theme while running

    Oh, QWidget::setStyle() seems to be somehow broken at least in Qt 4.5.0-beta1. Yeah, QApplication::setStyle() still works.
    J-P Nurmi

  10. The following user says thank you to jpn for this useful post:

    Macok (12th February 2009)

  11. #8
    Join Date
    Jan 2009
    Posts
    51
    Thanks
    28
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Change Qt theme while running

    Ok, thanks jpn!

Similar Threads

  1. change operating system theme.
    By rajeshs in forum Qt Programming
    Replies: 2
    Last Post: 20th March 2008, 04:02

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.