qt - Drop-down button in QToolBar with changing fields -
i'm bit stucked creating drop-down button based on qaction
placed in qtoolbar
have xml file following data:
<cfg> <fields> <group name="first fields"> <field>filed1</field> <field>filed2</field> <field>filed3</field> </group> <group name="second fields"> <field>filed4</field> <field>filed5</field> <field>filed6</field> ... etc ... </group> </fields> <button name="mybutton1" /> <button name="mybutton2 /> ... etc ... </cfg>
nb: don't know how field groups be, don't know how button be.
so, first of all, parse following xml-file , extract needed data.
for each button
create own qaction
, add existing toolbar.
later, create qmenu
each button , fill qaction
s each group , field. have qaction
first fields
, field1
, field2
, etc...
then, each button
use setmenu
method , add created menus there.
if launch app can see buttons in toolbar drop-down menus , looks expected.
the problem here need add functionality buttons.
i'd allow user check them (i use setcheckable
qactions
) , uncheck. when user checks actions group name fields related group become checked , on.
as don't know how buttons , fields have on startup become difficult work signals , slots.
forces me use qmap
store addresses of created qaction
, when signals fields being emited, using find method actions emited , them perform needed action.
the question is: there better way achieve goal or should continue using approach?
if don't know how many items going created, advice use qsignalmapper (documentation here).
first reference each item variable in qsignalmapper, connect signal want (coming item) signal mapper. connect qsignalmapper single slot, receive reference variable. several signal mappers can used if need connect different kinds of signals.
you still have store each item somewhere, think way go.
Comments
Post a Comment