Results 1 to 7 of 7

Thread: Dynamically changing QFrame color

  1. #1
    Join Date
    Jan 2006
    Location
    Berkeley California
    Posts
    109
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Dynamically changing QFrame color

    How can I dynamically change the color of a QFrame border (shape = box, shadow = plain) ?

    Thanks

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Dynamically changing QFrame color

    You can use QPalette for this.

  3. #3
    Join Date
    Jan 2006
    Location
    Berkeley California
    Posts
    109
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Dynamically changing QFrame color

    Does a QFrame have Disabled, Active and Inactive states that can be set to change its color or is changing the palette the only way to do this?

    Thanks

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

    Default Re: Dynamically changing QFrame color

    Use QPalette::setColor(ColorGroup gr, ColorRole r, const QColor & c) where the color group is one of the following:
    • QPalette::Disabled
    • QPalette::Active
    • QPalette::Inactive
    • QPalette::Normal
    J-P Nurmi

  5. #5
    Join Date
    Jan 2006
    Location
    Berkeley California
    Posts
    109
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Dynamically changing QFrame color

    OK, but what ColorRole do I use?

    Thanks

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

    Default Re: Dynamically changing QFrame color

    Experiment. There is a preview if you use Designer. There is also another possibility if you use 4.2 - String (aka Style) Sheets.

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

    gimel (16th October 2008)

  8. #7
    Join Date
    Oct 2008
    Posts
    11
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Dynamically changing QFrame color

    Under Vista+Qt 4.4.1, QPalette is not functional for this. Use frame->setStyleSheet("color:red") to change the border color.

Similar Threads

  1. QLabel background color
    By munna in forum Newbie
    Replies: 3
    Last Post: 1st May 2006, 16:36
  2. Changing the text color of a QTreeView leaf.
    By johnny_sparx in forum Qt Programming
    Replies: 3
    Last Post: 23rd March 2006, 00:58

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.