PDA

View Full Version : icon modes and mask for checkable pushbutton question



TheClassic
28th July 2011, 16:15
I have an image I want to use as a button: http://i.imgur.com/SCpnN.png
I also a modified (rotated) version of the image that I want to use for when the button is actively being pressed, and another for when the button is "checked".
I have two problems. First, when the button is pressed it correctly shows the "active" icon, however it doesn't switched to the appropriate "checked" or "unchecked" icon until the button loses focus. I can set the focus policy to NoFocus, but then the active mode never occurs.
Here is my code

icon.addFile("..\\sb\\images\\collapseArrow.png", size, QIcon::Normal, QIcon::Off);
icon.addFile("..\\sb\\images\\collapseArrow.png", size, QIcon::Selected, QIcon::Off);
icon.addFile("..\\sb\\images\\collapseArrowActive.png", size, QIcon::Active, QIcon::Off);
icon.addFile("..\\sb\\images\\collapseArrowActive.png", size, QIcon::Active, QIcon::On);
icon.addFile("..\\sb\\images\\collapseArrowCollapsed.png", size, QIcon::Normal, QIcon::On);
icon.addFile("..\\sb\\images\\collapseArrowCollapsed.png", size, QIcon::Selected, QIcon::On);

Second, I ONLY want the icon to display for the button, I don't want to see the button border (see image below) or see it shaded when its pressed, etc. Normally I would use a mask created from the same image used for the button. However, I a) want the clickable region to be larger than the image and the image changes as described above.
http://imgur.com/yOjws.jpg

Thanks for any help you guys can give me

TheClassic
29th July 2011, 15:08
Since I wanted the clickable region to be larger than the icon anyway, I just used a label instead of a button, and handled the mouse events myself