Results 1 to 13 of 13

Thread: Removing gradient from QPushButton

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2008
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Removing gradient from QPushButton

    Quote Originally Posted by marcel View Post
    I think the property for the back color is background-color, not background.
    I tried background-color first and then tried background just to see if it made any difference and it didn't change anything.

  2. #2
    Join Date
    Feb 2008
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Removing gradient from QPushButton

    I found a way to get the buttons to have a solid color background.

    Qt Code:
    1. pushButton->setStyleSheet("background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 white, stop: 1 white);");
    To copy to clipboard, switch view to plain text mode 

    Now the question becomes why do I have to use a qlineargradient to get the QPushButton to be a solid color.

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

    Default Re: Removing gradient from QPushButton

    Does the problem occur with all widget styles or a particular one (probably plastique)?

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

    Lexrst (22nd April 2008)

  5. #4
    Join Date
    Feb 2008
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Removing gradient from QPushButton

    Quote Originally Posted by wysota View Post
    Does the problem occur with all widget styles or a particular one (probably plastique)?
    The style of the widget seems to be the cause of my problem. All other styles I tried (CDE, Motif, Cleanlooks, Windows) seem to work as expected, giving me the solid color background I expected. Only Plastique seems to have the issue described in this thread.

    So I have a way to accomplish what I need but now the question becomes..
    Why does the plastique style override what I put in the StyleSheet and force it to be a gradient when I specify a single color?

    Thanks for a push in the right direction!

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

    Default Re: Removing gradient from QPushButton

    What happens if you overload the style for different states of the button like :hover?


    QPushButton, QPushButton:hover { background: white; color: black; }

  7. #6
    Join Date
    Feb 2008
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Removing gradient from QPushButton

    Quote Originally Posted by wysota View Post
    What happens if you overload the style for different states of the button like :hover?


    QPushButton, QPushButton:hover { background: white; color: black; }
    Sorry for not getting back to this sooner. Been focused on other projects.

    If I overload for :hover, with the above sytnax, using the Plastique style I still don't get a solid color background in the button, it's a white to grey gradient. I get similar results if I overload for :pressed with the same syntax.

    So I'm using a qlineargradient to get a solid color background for my QPushButton, when using the Plastique style.

    From my testing this only appears to happen with the Plastique style and not with any other sytle that I tried.

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

    Default Re: Removing gradient from QPushButton

    This might be a bug in stylesheets or plastique.

  9. #8
    Join Date
    Feb 2008
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Removing gradient from QPushButton

    Quote Originally Posted by wysota View Post
    This might be a bug in stylesheets or plastique.
    Along the lines of what I was thinking.

    It's as if the QStyle is being applied no matter what I specify in the style sheet, when the plastique style is used. Other styles I tried, behaved as I expected when stylesheets were used to modify the look of the QPushButton.

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.