[Qt-interest] QActions don't appear in QMenu
Constantin Makshin
cmakshin at gmail.com
Thu Jul 15 10:19:40 CEST 2010
On Wednesday 14 July 2010 23:39:28 Oszkar Ambrus wrote:
> On 14/07/10 20:33, Constantin Makshin wrote:
> > That's strange.
> >
> > I've made a "quick and dirty" test application (see the attachment) and everything works as expected.
>
> Wow, cool, thanks! :)
> I think it has to do with parenting. Weird... I have to see what I can do.
In that test application one of actions in the menu belongs to the button which is a child widget of the application's window. So, just like in your code, menu and action have different parents.
But I admit that your case is somewhat more complex because, if I understood right, your widget and action are created in a plug-in instead of the main application. May be Qt forbids adding "foreign" actions for some reason, e.g. to avoid dangling pointers if the plug-in is unloaded. I can't say it for sure. A comment from Qt developers would be appreciated.
> > By the way, your connect() call looks a bit weird, too — the signal has a parameter, but the slot does not.
>
> The signal is that way, because the parameterless one is not emitted (I
> checked the source code), but I don't need the parameter.
"triggered()" signal's parameter has a default value, i.e. it's optional and you don't have to specify it explicitly if you don't need it.
> Regards,
> Oszkar
More information about the Qt-interest-old
mailing list