Results 1 to 10 of 10

Thread: Set appropriate style for the user's platform ?

  1. #1
    Join Date
    May 2006
    Posts
    108
    Thanks
    35
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Question Set appropriate style for the user's platform ?

    Hi,

    i set the application style like this:
    Qt Code:
    1. QApplication::setStyle(QStyleFactory::create(styleName));
    To copy to clipboard, switch view to plain text mode 
    then i will set the most appropriate style for the user's platform or desktop environment and try that:
    Qt Code:
    1. QApplication::setStyle(0);
    To copy to clipboard, switch view to plain text mode 
    but the style don't change to the the most appropriate style!

    How can i do that?

    Thanks in advance,

    Whitefurrows

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Set appropriate style for the user's platform ?

    Is styleName in the list that QStyleFactory::keys returns?
    As far as I know there is no need to override manually the style, because the platform style is used by default.

    Anyway, you can rest assured that WinXP style won;t be set by default on another platform than Windows, or Mac style on other platform than Mac.

    I say this from experience.

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

    whitefurrows (22nd May 2007)

  4. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Set appropriate style for the user's platform ?

    I'll say even more. WinXP style won't be set on systems older than WinXP

  5. #4
    Join Date
    May 2006
    Posts
    108
    Thanks
    35
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Set appropriate style for the user's platform ?

    Yes, the styleName is in the list that QStyleFactory::keys returns for example i set "plastique":
    Qt Code:
    1. QApplication::setStyle(QStyleFactory::create("plastique"));
    To copy to clipboard, switch view to plain text mode 

    Yes the platform style is used by default, but my problem is, i set a style like ("plastique") and can't reset to the platform default style.

    In Qt 3.3 i can do it with:
    Qt Code:
    1. QApplication::setStyle(0);
    To copy to clipboard, switch view to plain text mode 
    but Qt 4.2 do nothing.

    The problem is not a dependent style like "windowsxp" and "macintosh", you know what i mean?

  6. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Set appropriate style for the user's platform ?

    Why not store the name of the default style before setting the new one?

  7. #6
    Join Date
    May 2006
    Posts
    108
    Thanks
    35
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Set appropriate style for the user's platform ?

    How can i store the default style?

  8. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Set appropriate style for the user's platform ?

    Qt Code:
    1. QString name = QApplication::style().objectName();
    To copy to clipboard, switch view to plain text mode 

  9. The following user says thank you to wysota for this useful post:

    whitefurrows (22nd May 2007)

  10. #8
    Join Date
    May 2006
    Posts
    108
    Thanks
    35
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Set appropriate style for the user's platform ?

    Thank you, i can use it, but i think that's not fine. Is no function available like this:
    Qt Code:
    1. QApplication->setStyle(QApplication->defaultStyle());
    To copy to clipboard, switch view to plain text mode 

  11. #9
    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: Set appropriate style for the user's platform ?

    Quote Originally Posted by whitefurrows View Post
    Thank you, i can use it, but i think that's not fine. Is no function available like this:
    Qt Code:
    1. QApplication->setStyle(QApplication->defaultStyle());
    To copy to clipboard, switch view to plain text mode 
    AFAIK, nothing like that exists. You can send suggestions via Task-Tracker.
    J-P Nurmi

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

    whitefurrows (22nd May 2007)

  13. #10
    Join Date
    May 2006
    Posts
    108
    Thanks
    35
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Thumbs up Re: Set appropriate style for the user's platform ?

    Thanks at all. I try it and send my suggestions via Task-Tracker.

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.