Results 1 to 7 of 7

Thread: Changing the colour of an individual widget

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2006
    Location
    Australia
    Posts
    53
    Thanks
    11
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Changing the colour of an individual widget

    ok - I am struggling a bit with my styles......
    I want to have a uniform style for the whole application, and then I want to be able to make a couple of the key widgets stand out by changing them to a second style....


    basically what I do is
    Qt Code:
    1. int main(int argc, char*[] argv)
    2. {
    3. QApplication app(argc, argv);
    4. app.QApplication::setStyle(new TopLayoutStyle);
    5. .....
    6. MyTabWidget* topRight = new MyTabWidget();
    7. MyQPalette* palette = topRight->getPalette();
    8. palette->changeColour();
    9. topRight->QWidget::setPalette(bottomColours);
    10. .......
    11. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. MyQPalette::changeColour()
    2. {
    3. QColor greenShadow(98, 161, 98);
    4. QColor green(112, 181, 112);
    5. QColor greenLight(116, 195, 116);
    6. QColor greenMid(95,135,95);
    7. QColor greenForeground(167, 210, 183, 63);
    8. QColor greenDark(80, 140, 80);
    9. QColor midYellow(255, 235, 0);
    10.  
    11. this->setBrush(QPalette::BrightText,greenForeground);
    12. this->setBrush(QPalette::Base, green);
    13. this->setBrush(QPalette::Highlight, greenForeground);
    14. this->setBrush(QPalette::Background, green);
    15. this->setBrush(QPalette::Light, greenLight);
    16. this->setBrush(QPalette::Mid, greenMid);
    17. this->setBrush(QPalette::Dark, greenDark);
    18. this->setBrush(QPalette::Button, green);
    19. this->setBrush(QPalette::Window, green);
    20. }
    To copy to clipboard, switch view to plain text mode 
    now for the most part this is cool, all the buttons/outlines etc change on the tabs widget which I want to stand out....only prob is that the background does not change colour even though everything else does
    i've attached a screen shot
    I can't work out why the background of the tab widget appears to be filled with the background of the application instead of its own background unhappy

    (and yes, I know the screen layout is pretty crappy at the moment - i'm still just experimenting and getting my custom widgets to look right)

    thanks guys
    Attached Images Attached Images
    Last edited by georgie; 1st May 2006 at 02:00.

Similar Threads

  1. QDockWidget inside another widget in the center?
    By Antebios in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2010, 07:06
  2. Replies: 1
    Last Post: 8th February 2009, 11:37
  3. Changing QPushButton text colour with mouseMoveEvent
    By Misenko in forum Qt Programming
    Replies: 1
    Last Post: 10th June 2008, 16:53
  4. Changing colour thru qss file
    By phillip_Qt in forum Qt Programming
    Replies: 3
    Last Post: 27th March 2008, 05:36
  5. Dynamically changing QLabel background colour
    By T4ng10r in forum Qt Programming
    Replies: 19
    Last Post: 19th April 2007, 12:47

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
  •  
Qt is a trademark of The Qt Company.