... just getting back to this task ...
Now my challenge is to get the tool button not to paint a button background when it auto-raises. I want to control the pixmaps shown in QIcon::Normal and Active modes, and QIcon::Off and On states. My QToolbutton items are auto-raise and checkable. The underlying label pixmap shows through nicely when I set the tool button icon to be semi-transparent, as in
QSize size
= tool_button
->size
();
tool_button
->setIconSize
(size
- QSize(10,
10));
pixmap.
fill(QColor(0,
0,
0,
50));
tool_button->setIcon(icon);
QToolButton *tool_button = Ui.ToolButtonTest;
QSize size = tool_button->size();
tool_button->setIconSize(size - QSize(10,10));
QPixmap pixmap(size);
pixmap.fill(QColor(0,0,0,50));
QIcon icon;
icon.addPixmap(pixmap,QIcon::Active,QIcon::On);
tool_button->setIcon(icon);
To copy to clipboard, switch view to plain text mode
But the when the tool button auto-raises or is "checked", the style engine appears to paint a system style dependent frame and background that I cannot suppress. We normally want this behavior, but it's not what I want here. I tried changing every color role in the toolbutton's palette to a transparent color, which helped a little in some styles but is not robust or complete.
Should I abandon QToolButton and create my own button subclass, re-implementing mouse events to create the auto-raise behavior I want? I was hoping to write a little less code and use Designer to just place tool buttons.
I'm using Qt 4.3.3 on XP.
Any suggestions?
thanks
Bookmarks