Results 1 to 4 of 4

Thread: Change color of QButton does not work with GTK

  1. #1
    Join Date
    Aug 2006
    Location
    The Netherlands
    Posts
    64
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Change color of QButton does not work with GTK

    I'm using Qt 4.5.0

    I use this code to change the color of a QButton:
    Qt Code:
    1. SigColorButton->setPalette(QPalette((Qt::GlobalColor)mainwindow->maincurve->signal_color));
    To copy to clipboard, switch view to plain text mode 

    This works with Plastic and windows style but not with GTK style...

    After compilation, when I run the app with "app -style plastic" or "app -style windows" it's ok. It's not ok when I try "app -style gtk".

    OS is Linux, tried on OpenSUSE and Ubuntu. GTK2 development files are installed and Qt was configured to use GTK-style.
    The GTK-style does work, problem is that I can not change the color of a QButton when using GTK style.

    Any ideas?

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

    Default Re: Change color of QButton does not work with GTK

    Use stylesheets. Some styles (apparently GTK included) don't allow to change the looks of some items, like colours of buttons because the underlying backend (such as Vista's Aero) doesn't support such operations and the style is not emulated but used.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Teuniz (19th March 2009)

  4. #3
    Join Date
    Aug 2006
    Location
    The Netherlands
    Posts
    64
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Change color of QButton does not work with GTK

    Quote Originally Posted by wysota View Post
    Use stylesheets. Some styles (apparently GTK included) don't allow to change the looks of some items, like colours of buttons because the underlying backend (such as Vista's Aero) doesn't support such operations and the style is not emulated but used.
    Thanks, what do you mean with stylesheets?
    I don't want to change the style and/or all the buttons.
    I have two dialogs with some buttons and only these particular buttons needs to be recoloured.

    Isn't it better to write my own buttonwidget or inherit from QButton and change some properties?

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

    Default Re: Change color of QButton does not work with GTK

    Quote Originally Posted by Teuniz View Post
    Thanks, what do you mean with stylesheets?
    Qt Stylesheets

    Isn't it better to write my own buttonwidget or inherit from QButton and change some properties?
    It wouldn't change anything. You'd have to draw the whole button yourself.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Change work area OS
    By pakulo in forum Qt Programming
    Replies: 15
    Last Post: 15th May 2007, 07:20

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.