"." instead of "->"
because with the "->" I got a compiling error!
"." instead of "->"
because with the "->" I got a compiling error!
Sure, I forgot you don't have a palette pointer![]()
but the button is still gray!
![]()
![]()
![]()
arrrr it is green!!!![]()
![]()
I even dont know what my mistake was!!
How can i use colors which are net predefined??
Is it possible to enter anywhere a RGB code???
Or something else?
Best Regards, and thx
Yes, you can construct a custom color with QColor( R, G, B ).
Look at QColor.
Regards
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
A few notes:
It is a good practice to get the palette from a widget, modify it, and set it back. Constructing a new palette object makes it use application's default palette which means losing any possible previous modifications to widget's palette:
Qt Code:
palette.setColor(...); widget->setPalette(palette);To copy to clipboard, switch view to plain text mode
For a button, the correct color group is QPalette::Button:
Qt Code:
button->setPalette(palette);To copy to clipboard, switch view to plain text mode
QWindowsXpStyle and QMacStyle use native theming engines which cause some palette modifications not to have any effect. Certain colors/brushes/whatever come from the underlying system. Style sheets is the solution to this problem. Follow the link and see the example of changing QPushButton's color there.
J-P Nurmi
I got a runtime exception: Segmentation fault!
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:
QColor myColor; mycolor.setRgb(0, 150, 0, 255); ... ... ... To copy to clipboard, switch view to plain text mode
It works fine!
Best Regards,...
fnmblot (25th April 2007)
Now try changing your application to a different style... Especially try the WindowsXP style.
give me a hint, please!![]()
Qt Code:
To copy to clipboard, switch view to plain text mode
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 ??
Did u try it on windows ??
What do you mean???
Compiling this SourceCode on Windows?
No I didn't try that.
Best Regards
If your code is meant to run on Windows too then I suggest you do that now and run it under WinXP.
My code isn't suggested to run under WXP .... net yet??
Will there be much problems with colored buttons on WXP?
Bookmarks