Page 2 of 2 FirstFirst 12
Results 21 to 34 of 34

Thread: Colored Buttons

  1. #21
    Join Date
    Mar 2007
    Location
    Vienna / Austria
    Posts
    54
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default Re: Colored Buttons

    Quote Originally Posted by marcel View Post
    Yes, if you use a QTimer, with let's say a 200ms delay. In the timerEvent slot you just switch the color from gray to green and then back.

    Regards
    How can I find out which gray is the standard gray!!!! So that the Button looks like a button with no specific color??



    Best Regards?

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

    Default Re: Colored Buttons

    Now try changing your application to a different style... Especially try the WindowsXP style.

  3. #23
    Join Date
    Mar 2007
    Location
    Vienna / Austria
    Posts
    54
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default Re: Colored Buttons

    give me a hint, please!

  4. #24
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    99
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    11
    Thanked 3 Times in 3 Posts

    Default Re: Colored Buttons

    Quote Originally Posted by Walsi View Post
    give me a hint, please!
    Qt Code:
    1. QColor oldButtonColor = pushButton->palette().color(QPalette::Button);
    To copy to clipboard, switch view to plain text mode 

  5. #25
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 334 Times in 317 Posts

    Default Re: Colored Buttons

    Walsi, which OS were you using ??
    I was using the same code to change the color of the button...
    setPalette(QPalette(QColor(m_color)));
    but i was using the button as Flat, and hence the color showed properly. I removed the flat property and it doesnt draw color on the button... i tried various roles like QPalette::Button , etc to change the color, but still no help

    Is it bec as Jpn suggested that native themes cause some effects not to have the desired effect ??

  6. #26
    Join Date
    Mar 2007
    Location
    Vienna / Austria
    Posts
    54
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default Re: Colored Buttons

    Quote Originally Posted by Walsi View Post
    Now I tried a solution which causes no error and which seems to be working.

    My code is looking like that:

    I generate my own color out from a RGB code (also with alpha Parameter)

    Qt Code:
    1. QColor myColor;
    2. mycolor.setRgb(0, 150, 0, 255);
    3.  
    4. ...
    5. ...
    6. ...
    7.  
    8. myButton->setPalette(QPalette(Qcolor(myColor)));
    To copy to clipboard, switch view to plain text mode 


    It works fine!

    Best Regards,...
    I use this code for changing the color of buttons and my operating system is KUBUNTU!
    I think version 6.10

  7. #27
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 334 Times in 317 Posts

    Default Re: Colored Buttons

    Did u try it on windows ??

  8. #28
    Join Date
    Mar 2007
    Location
    Vienna / Austria
    Posts
    54
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default Re: Colored Buttons

    What do you mean???

    Compiling this SourceCode on Windows?

    No I didn't try that.

    Best Regards

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

    Default Re: Colored Buttons

    If your code is meant to run on Windows too then I suggest you do that now and run it under WinXP.

  10. #30
    Join Date
    Mar 2007
    Location
    Vienna / Austria
    Posts
    54
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default Re: Colored Buttons

    My code isn't suggested to run under WXP .... net yet??

    Will there be much problems with colored buttons on WXP?

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

    Default Re: Colored Buttons

    Just try it and you're see for yourself. If you ever plan to run the application on Windows or MacOSX, I suggest you check out the "red button issue" on all platforms

  12. #32
    Join Date
    Mar 2007
    Location
    Vienna / Austria
    Posts
    54
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default Re: Colored Buttons

    Okay,...

    I will!

  13. #33
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    111
    Thanked 4 Times in 4 Posts

    Default Re: Colored Buttons

    Now, if the push button is previously set as flat, marcel's way is not working. How to change a background color of flat push button?
    Qt 5.3 Opensource & Creator 3.1.2

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

    Default Re: Colored Buttons

    I won't read the whole thread again, but I'm sure the proper answer is "use stylesheets".

Similar Threads

  1. Main window with custom buttons ?
    By probine in forum Qt Programming
    Replies: 1
    Last Post: 22nd November 2006, 07:32
  2. array of radio buttons
    By amulya in forum Qt Programming
    Replies: 4
    Last Post: 5th October 2006, 13:59
  3. widget for text AND buttons
    By nongentesimus in forum Newbie
    Replies: 2
    Last Post: 16th June 2006, 14:43
  4. Replies: 9
    Last Post: 9th May 2006, 20:53
  5. How to get larger radio buttons on XP?
    By Ben.Hines in forum Qt Programming
    Replies: 9
    Last Post: 24th April 2006, 20:00

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.