You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Tuesday, December 20th 2011, 8:12pm

How to change tooltip color of a QPushbutton on Windows7

Hello,
I would like to change tooltip both front and background color of a QPushButton object. My environment is
Windows7 Professional SP1 64bit, MSVC2008, Qt 4.7.2 (32bit).
However with below code, I only see the effect of QToolTip::setFont(), but not ::setBrush() or ::setColor(). I vaguely remember that QToolTip on Windows XP and Windows 7 behaves differently. On Windows XP, QToolTip background and front colors are the same as the parent QPushButton. On Windows 7, QToolTip background and front colors are uniform for all QPushButton's and cannot be modified. In my case, the background color is light gray with gradient. And front color is white. These results a very LOW contrast. Would you please confirm this? Or would you please hint me to how to change them? Thanks a lot.
Happy Holidays!
casestudy

Source code

1
2
3
4
5
6
7
8
9
QBrush brushToolTipBase(Qt::white);
QBrush brushToolTipText(Qt::red);
QPalette palette = QToolTip::palette();	 
palette.setBrush(QPalette::ToolTipBase, brushToolTipBase);	 
palette.setBrush(QPalette::ToolTipText, brushToolTipText);	 
palette.setColor(QPalette::ToolTipBase, Qt::white);	 
palette.setColor(QPalette::ToolTipText, Qt::red);	
QToolTip::setPalette(palette);QFont serifFont("Times", 14, QFont::Bold);	
QToolTip::setFont(serifFont);

2

Thursday, December 22nd 2011, 3:23pm

Thanks for reading. The solution has been proposed here.
http://www.qtcentre.org/threads/46515-Ho…ed=1#post210233