Results 1 to 5 of 5

Thread: color one half of the button?

  1. #1
    Join Date
    Nov 2007
    Posts
    103
    Thanks
    71
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default color one half of the button?

    Hello,

    I know how to change the background color of a pushbutton:

    Qt Code:
    1. colorButton->setStyleSheet("background:rgb(100,150,200);");
    To copy to clipboard, switch view to plain text mode 

    But is it also possible, using style sheets, to make one half of the button one color
    and the second half another color? How?

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

    Default Re: color one half of the button?

    Yes, use gradient.
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    tommy (26th December 2007)

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

    Default Re: color one half of the button?

    Yes... it is possible using a linear gradient. But.... what for?

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

    tommy (26th December 2007)

  6. #4
    Join Date
    Nov 2007
    Posts
    103
    Thanks
    71
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: color one half of the button?

    Thanks!

    I don't really want gradient, I need left side of the button to be one color and
    right side a different color with a sharp border. How would you do that? Are there any examples out there with the syntax?

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

    Default Re: color one half of the button?

    Quote Originally Posted by tommy View Post
    I don't really want gradient, I need left side of the button to be one color and right side a different color with a sharp border. How would you do that? Are there any examples out there with the syntax?
    A linear gradient is still fine. Remember, you can define a color at any stop. Try something like:
    Qt Code:
    1. background: qlineargradient(x1:0, y1:0, x2:1, y2:0,
    2. stop:0.5 red, stop:0.5 blue);
    3. border: ...
    4. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  8. The following user says thank you to jpn for this useful post:

    tommy (26th December 2007)

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.