c++ - MOC a lambda connection -
i'd create connection so:
connect(mymap[myobjectname], &myobject::valuechanged, [&] (int value) { qstring objectname = sender()->objectname(); myothermap[objectname].setvalue(qvariant(value)); });
this doesn't work though because sender() can't invoked without function going through moc. thus, way create work (seemingly) using old signal/slot string based syntax.
however, things this qt blog create seem qt5 function pointer syntax should preferred on previous string syntax, i'm curious: there way moc lamda function, or there whole class of cases new syntax can't used?
use this
(or other qobject
) receiver create sender()
method work:
connect(mymap[myobjectname], &myobject::valuechanged, this, [&] (int value) { qstring objectname = sender()->objectname(); myothermap[objectname].setvalue(qvariant(value)); });
or take @ qsignalmapper. looks fit scenario.
c++ qt lambda moc
No comments:
Post a Comment