Results 1 to 3 of 3

Thread: Custom painting and stylesheets

  1. #1
    Join Date
    Mar 2009
    Location
    Belchatow, Poland
    Posts
    38
    Thanks
    11
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Custom painting and stylesheets

    I'm not sure if it's possible, but I would like to achive something like this:
    I have a class that inherits QWidget, it uses paintEvent to draw some text and rectangles, what I would like to achive is get color of text and those rectangles from style sheet.

    Pseudocode:

    C++
    Qt Code:
    1. QColor color = this->getStyleSheet().getClass('MyWidget').getProperty('color');
    To copy to clipboard, switch view to plain text mode 

    CSS
    Qt Code:
    1. .MyWidget {
    2. color: #cdcdcd;
    3. }
    To copy to clipboard, switch view to plain text mode 

    Is it possible to do in QT or do I have to store colors and other style information some other way?

  2. #2
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Custom painting and stylesheets

    Is it necessary that you get the information from a css format? If so I believe you would have to roll your own parser. However you could easily do the same thing using XML which Qt does have support for.

  3. #3
    Join Date
    Mar 2009
    Location
    Belchatow, Poland
    Posts
    38
    Thanks
    11
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Re: Custom painting and stylesheets

    It's a little strange that QT allows setting style sheets but not getting any style properties, I mean it surely has some CSS parser, I guess it's not public.

    Ok then, I'm gonna go with XML, thanks

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.