Is it possible to have a custom icon displayed for a QAction when it is disabled? E.g. display icon A when the tool is enabled and icon B when the tool is disabled.
Is it possible to have a custom icon displayed for a QAction when it
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When creating a
QAction, you pass it aQIcon. Although I haven’t tried this myself, I’ve noticed thatQIconhas a functionvoid QIcon::addPixmap ( const QPixmap & pixmap, Mode mode = Normal, State state = Off ). TheModecan be one ofNormal,Disabled,Active, orSelected. Thus, I presume something like this would work:I would be interested in learning if this actually does work. I’ve never gotten around to testing it, but it seems like exactly the use this was designed for.