PDA

View Full Version : QToolBoxitem issue



AlbertoN
16th April 2013, 21:04
Hi all,

i'm posting because i can't set a QToolBox's iconset with QToolBox's addItem method. For iconset i mean an icon which can change on item changes...

I'll try to provide a snippet of code:


QIcon m_icon;
m_icon.addFile(":/icons/selected.png",QSize(),QIcon::Active,QIcon::On);
m_icon.addFile(":/icons/selected.png",QSize(),QIcon::Normal,QIcon::On);
m_icon.addFile(":/icons/selected.png",QSize(),QIcon::Disabled,QIcon::On);
m_icon.addFile(":/icons/selected.png",QSize(),QIcon::Selected,QIcon::On);

m_icon.addFile(":/icons/unselected.png",QSize(),QIcon::Active,QIcon::Off);
m_icon.addFile(":/icons/unselected.png",QSize(),QIcon::Normal,QIcon::Off);
m_icon.addFile(":/icons/unselected.png",QSize(),QIcon::Disabled,QIcon::Off);
m_icon.addFile(":/icons/unselected.png",QSize(),QIcon::Selected,QIcon::Off);
...
QToolBox *tb = new QToolBox(this);
tb->addItem(new QWidget(this),m_icon,"example");


even if resource path are right, there are no typo and so on it doesn't work. Reading on google maybe i get the point: changes happens only if the button's checkable property is true. So button saves its "state".
Infact i tried to implement a little example with designer and it works only if i set that property. My issue is that there is no way to set up that property on standard QToolBox's item.
I missed something important or could it be a QToolBox's bug?
I'm going to attach my simple designer example(toolboxbutton.zip) so anyone can check it works properly and another example using QToolBox's standard item (notworking.zip)

Thanks for your help.
Alberto

ChrisW67
17th April 2013, 04:57
Ok, so we know it "doesn't work" but we have no idea what you were expecting to happen.

The On state is only relevant if the widget is checkable/toggle-able.
The Active mode Off state would need to be different to the other Off state images if you ware expecting a on-hover or while-clicked change.
The separate images are only used by widgets that a written to use them.

AlbertoN
17th April 2013, 09:02
I'd like that icon change on click, to highlight current "selected" tab, as it happens on QToolBox (like) used in Qt Designer to hold widgets...
Reading source code of QToolBox as far as I could understand the button is just a QToolButton, to let it work you should only provide a QToolBox::setCheckable method to change its state...that's all :)