Results 1 to 4 of 4

Thread: QPalette works differently on windows and linux

  1. #1
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default QPalette works differently on windows and linux

    hi
    i want to change color of push button .

    the does this in linux but in windows it does not work .
    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char *argv[])
    4. {
    5. QApplication a(argc, argv);
    6.  
    7. b.show();
    8.  
    9. QPalette palette;
    10. QBrush brushg(QColor(0, 255, 0, 255));//green
    11. palette.setBrush(QPalette::Active, QPalette::Button, brushg);
    12. b.setPalette(palette);
    13.  
    14. return a.exec();
    15. }
    To copy to clipboard, switch view to plain text mode 

    the above program displays a pushbutton in green color in linux, but the same program after compiling in windows and running the color of pushbutton is not green in color.

    the same is with the designer. i can change the color of pushbutton using designer in linux but in windows it does not work.

  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: QPalette works differently on windows and linux

    Yes, it doesn't work on WinXP because QWindowsXpStyle uses native theming engine. It wouldn't work on Mac either.

    Next time, please search the forums before starting new threads. This question has been asked and answered (too) many times, last time yesterday. There's even a FAQ entry: How to change the colour of a button or any other Qt widget?
    J-P Nurmi

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

    babu198649 (6th March 2008)

  4. #3
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default Re: QPalette works differently on windows and linux

    thanks for the link jpn.

    in the link the code sets pushbutton to red color.
    Qt Code:
    1. button->setStyleSheet("color: #0000dd; background-color: red;");
    To copy to clipboard, switch view to plain text mode 

    but even if we use
    Qt Code:
    1. button->setStyleSheet("background-color: red;");
    To copy to clipboard, switch view to plain text mode 

    this we get the same ,then what does color: #0000dd signify and do we really need it. i have gone through the docs(The Style Sheet Syntax) and i have not found any thing like this.

  5. #4
    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: QPalette works differently on windows and linux

    Quote Originally Posted by babu198649 View Post
    i have gone through the docs(The Style Sheet Syntax) and i have not found any thing like this.
    Really? It's all explained in the list of stylable properties: http://doc.trolltech.com/4.3/stylesh...tml#color-prop
    J-P Nurmi

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

    babu198649 (6th March 2008)

Similar Threads

  1. Replies: 19
    Last Post: 21st January 2008, 09:13
  2. Project won't compile under Windows (works under Linux)
    By philski in forum Qt Programming
    Replies: 7
    Last Post: 14th September 2006, 15:29

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.