Results 1 to 5 of 5

Thread: QColor with style sheets

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QColor with style sheets

    I got your code to work but I don't know what the syntax is to combine what you suggested into the same style sheet with the other style declarations. For example both of the style sheet declarations below work but I can't put them together into one. What is the syntax? Thanks a lot!
    Because the style sheet parameter is a QString, you can use all QString features, like the "+" and "+=" operators:
    Qt Code:
    1. mycolor = QColor(100,200,200);
    2. QString style = "background: rgb(%1, %2, %3);";
    3. style = style.arg(mycolor.red()).arg(mycolor.green()).arg(mycolor.blue());
    4. style += "color:black; font-size:12px;";
    5. style += "font-weight:bold;";
    6. drawButton->setStyleSheet(style);
    To copy to clipboard, switch view to plain text mode 

  2. The following 2 users say thank you to marcel for this useful post:

    giowck (3rd May 2012), tommy (27th December 2007)

Similar Threads

  1. BIG Problem with Background-image using Style Sheets
    By PiXeL16 in forum Qt Programming
    Replies: 1
    Last Post: 28th November 2007, 22:10
  2. BG image on QPushButton using style sheets??
    By JimDaniel in forum Newbie
    Replies: 2
    Last Post: 13th September 2007, 03:31
  3. Qt style sheets
    By locus in forum Qt Programming
    Replies: 5
    Last Post: 5th April 2007, 17:03
  4. style sheets
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 29th March 2007, 15:14
  5. Qt Style Sheets Problems with QDialog
    By Lykurg in forum Qt Programming
    Replies: 3
    Last Post: 5th November 2006, 14:43

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.