Results 1 to 4 of 4

Thread: Load palette from qss file

  1. #1
    Join Date
    Mar 2015
    Posts
    20
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Symbian S60

    Default Load palette from qss file

    Good morning to everybody!

    In the application I'm working on, I have to to show a temperature.
    I'm not dealing with a widget: just a rounded rect which width is proportional to the temperature and a text inside reporting the temperature value.
    The rect's background color shall be related to the temperature: i wants to define a palette filled with gradually changing colors from the one associated to the lowest temperature to the one associated to the highest.

    My customer wants to edit the palette content and use it without recompiling in order to define at release time the best color pattern in relation to the final application (ipse dixit!).

    1) Is there in the Qt world something to manage a palette in a look-up table meaning (QPalette seems to me related to widget-specifics colors...) ?

    My current purpose is to put the color values (say 255) in a qss file which is editable from the customer and loadable from the application in a smart way, so I ask:

    2) How to load those 255 color values from qss file in a non trivial way (= without having to define 255 different QPROPERTYes and related READ functions) ?

    Thank you very much for the time you'll spend in giving me some hint!

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Load palette from qss file

    Sounds to me as if the simplest solution would be to just read a list of strings from a text file.
    E.g. using QSetting with IniFormat. or a trivial text format with one color per line.

    Cheers,
    _

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Load palette from qss file

    You might also look at Qwt's QwtColorMap. This has several different versions that allow you to specify as few as two colors (start and end) that map to a real-world value range (0 - 100C, for example). You can also set color stops if you want to break the range into several sub-ranges, each with its own gradient. It is nearly a stand-alone class that can be used without the rest of the Qwt library (which by the way also has a "thermometer" widget in it).

  4. #4
    Join Date
    Mar 2015
    Posts
    20
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Symbian S60

    Default Re: Load palette from qss file

    That's really a grat hint! I already installed Qwt in order to use QwtPlot; so it's not a problem to try it!
    Thank you!

Similar Threads

  1. Load pls file with QMediaPlaylist
    By KeineAhnung in forum Newbie
    Replies: 1
    Last Post: 19th August 2014, 12:43
  2. Replies: 1
    Last Post: 19th March 2014, 22:25
  3. Load from a file to QSqlTableModel
    By dd44 in forum Qt Programming
    Replies: 4
    Last Post: 28th August 2012, 16:02
  4. How to load a .h or .cpp file in designer?
    By srohit24 in forum Qt Programming
    Replies: 2
    Last Post: 18th February 2009, 13:33
  5. Load ActiveX from file
    By Passer_dj in forum Qt Programming
    Replies: 1
    Last Post: 13th August 2007, 23:24

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.