[Qt-interest] QActions don't appear in QMenu

Oszkar Ambrus oszkar.ambrus at deri.org
Thu Jul 15 12:42:27 CEST 2010


On 15/07/10 11:19, Constantin Makshin wrote:
> On Wednesday 14 July 2010 23:39:28 Oszkar Ambrus wrote:
>> 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.

It's embarrassing, but I was actually recreating the widget after adding 
its actions to the menu. So the old widget would get deleted (with 
deleteLater()), and then the actions would disappear as well.

I'm really sorry about this!

>
>>> 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.

Yeah, I was using it, but when nothing worked, I tried changing all the 
little details. Thanks.

Regards,
Oszkar




More information about the Qt-interest-old mailing list