QToolBar not using QIcon::Mode
-
When I populated my ToolBar I used QIcons with four images, one for each QIcon::Mode.
So the code looks like this:
QIcon selRect; selRect.addFile("C:/Users/amonra/Documents/GitHub/DSS/DeepSkyStacker/Buttons/ButtonSelect_Up.bmp", iconSize, QIcon::Normal); selRect.addFile("C:/Users/amonra/Documents/GitHub/DSS/DeepSkyStacker/Buttons/ButtonSelect_Disabled.bmp", iconSize, QIcon::Disabled); selRect.addFile("C:/Users/amonra/Documents/GitHub/DSS/DeepSkyStacker/Buttons/ButtonSelect_Active.bmp", iconSize, QIcon::Active); selRect.addFile("C:/Users/amonra/Documents/GitHub/DSS/DeepSkyStacker/Buttons/ButtonSelect_Down.bmp", iconSize, QIcon::Selected); : : Similar for the other Icons : t.setOrientation(Qt::Vertical); QAction * rectAction = t.addAction(selRect, "", &editor, &DEditStars::rectButtonChecked); QAction * starsAction = t.addAction(selStars, "", &editor, &DEditStars::starsButtonChecked); QAction * cometAction = t.addAction(selComet, "", &editor, &DEditStars::cometButtonChecked); QAction * saveAction = t.addAction(saveButton, "", &editor, &DEditStars::saveButtonPressed); QActionGroup selectionGroup(&t); rectAction->setCheckable(true); starsAction->setCheckable(true); cometAction->setCheckable(true); selectionGroup.addAction(rectAction); selectionGroup.addAction(starsAction); selectionGroup.addAction(cometAction); selectionGroup.setExclusive(true);
But QToolBar appears to use only the QIcon::Normal version for all the buttons, and uses a small offset to indicate an item in the action group has been "checked", rather then using the QIcon::Selected image (I don't mind it keeping the small offset).
Also it doesn't ever use the QIcon::Active image when the mouse is over the button :(
Is it possible to persuade the Toolbar to do this, or do I need to build the tool bar the "hard way" by adding sub-classed QToolButton widgets?
-
@Bonnie Oh! OK, that's a surprise! I'd very much have expected the checked state to use QIcon::Selected.
I changed the code to do this:
QIcon selRect; selRect.addFile("C:/Users/amonra/Documents/GitHub/DSS/DeepSkyStacker/Buttons/ButtonSelect_Up.png", iconSize, QIcon::Normal); selRect.addFile("C:/Users/amonra/Documents/GitHub/DSS/DeepSkyStacker/Buttons/ButtonSelect_Active.bmp", iconSize, QIcon::Active); selRect.addFile("C:/Users/amonra/Documents/GitHub/DSS/DeepSkyStacker/Buttons/ButtonSelect_Down.bmp", iconSize, QIcon::Normal, QIcon::On);
and that does switch the icon for the checked state - thank you for that.
I'm guessing from what you didn't say that I can't get it to switch to the active Icon when the mouse is over the button without going down the sub-class route?