View Full Version : QAction color in toolbar
jmsbc
21st September 2009, 23:26
Hi, I have several buttons in my application's toolbar added with addAction(QAction * action). I was wondering how to change their color when hovered, and also another color when clicked.
Thanks
scascio
22nd September 2009, 09:22
If you means change the icon displayed on the toolbar, you can call QAction::setIcon in response of the hovered() and toggled(bool checked) signals
jmsbc
22nd September 2009, 21:52
Nope, I mean the background color of the button. I tried setting the pushbutton hover color:
this->setStyleSheet("QPushButton:hover {background-color:white}");
this->setStyleSheet("QPushButton:!hover { background-color: lightgray }");
But it does not apply to the QAction buttons in the toolbar. How do I change these colors? Thanks
KL-7
23rd September 2009, 06:06
You should use QToolButton stylesheet instead of QPushButton ;)
Another thing is that setStyleSheet method overwrite widget's stylesheet, so what you need is smth like that
this->setStyleSheet("QToolButton:hover {background-color:blue} QToolButton:!hover { background-color: lightgray }");
And if it's not the only usage of setStyleSheet in your app you should not overwrite stylesheet, but get it and append your new styles.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.