Results 1 to 6 of 6

Thread: How could QT apply style from an external CSS file?

  1. #1
    Join Date
    Dec 2010
    Posts
    9
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Maemo/MeeGo

    Default How could QT apply style from an external CSS file?

    Hi All,

    I would like the users to be able to customize the default look of our applications by simply loading their own CSS files. How do we accomplish that? Can anybody give me a jumpstart?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: How could QT apply style from an external CSS file?

    There is a -stylesheet commandline parameter QApplication supports. You can also just load the file directly in your app and apply its contents as the stylesheet of the application object.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Dec 2010
    Posts
    9
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Maemo/MeeGo

    Default Re: How could QT apply style from an external CSS file?

    So if were the user, all I have to do is create a QT Stylesheet, place it in a folder and run the application with the -stylesheet parameter?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: How could QT apply style from an external CSS file?

    You can place it anywhere you want as long as you tell the application where the file is. Just check the source code first, I'm not sure the switch is actually called -stylesheet.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Dec 2010
    Posts
    9
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Maemo/MeeGo

    Default Re: How could QT apply style from an external CSS file?

    The styles for the controls work but not when I'm trying to load a background image for the MainWindow. I tried:

    QMainWindow{
    background-image:url(image_256_8bit_latest_back.png);
    }

    Can you tell me what's wrong with this StyleSheet?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: How could QT apply style from an external CSS file?

    You are using a relative path.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 3
    Last Post: 25th February 2010, 08:53
  2. how to apply stylesheet to qtopia application using qss file
    By namita in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 31st March 2008, 07:04
  3. Replies: 4
    Last Post: 28th March 2008, 04:55
  4. Replies: 1
    Last Post: 27th November 2007, 10:10

Tags for this Thread

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.