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

Constantin Makshin cmakshin at gmail.com
Wed Jul 14 19:33:09 CEST 2010


That's strange.

I've made a "quick and dirty" test application (see the attachment) and everything works as expected.

By the way, your connect() call looks a bit weird, too — the signal has a parameter, but the slot does not.

On Wednesday 14 July 2010 19:58:46 Oszkar Ambrus wrote:
> On 14/07/10 18:39, Constantin Makshin wrote:
> > Then could you provide a small example so others can investigate the situation?
> 
> One widget (editPlugin) does this:
> QAction *showRelated = new QAction(KIcon("edit-find-project"),
>                                     i18n("Show related"),
>                                     this);
> connect(showRelated, SIGNAL(triggered(bool)),
>          this, SLOT(showRelatedResources()));
> addAction(showRelated);
> 
> The other one:
> actionsMenu->addActions(editPlugin->actions());
> actionsMenu->addAction("Test");
> btnActionsMenu->setMenu(actionsMenu);
> 
> As I said, it is in the menu (with the text "Show related"), isVisible() 
> and isEnabled() are true, but it still doesn't appear on the GUI, 
> whereas the action "Test" does.
> 
> Regards,
> Oszkar
> 
> 
> 
> >
> > On Wednesday 14 July 2010 18:47:32 Oszkar Ambrus wrote:
> >> On 14/07/10 17:33, Constantin Makshin wrote:
> >>> My assumption is that these actions either have empty text/title or are invisible.
> >>
> >> I checked that, and they don't have empty text, they are visible and
> >> enabled.
> >>
> >>>
> >>> On Wednesday 14 July 2010 18:13:20 Oszkar Ambrus wrote:
> >>>> Hi,
> >>>>
> >>>> I have this weird problem:
> >>>> I'm trying to add some QActions to a QMenu, but they do not appear in
> >>>> the list.
> >>>>
> >>>> The thing is that I get the actions from another widget (through its
> >>>> actions() method), and when I do that, they don't get displayed.
> >>>>
> >>>> I can query the menu for all the actions and it does contain them, but
> >>>> they just don't get displayed, whereas the ones I newly create, are visible.
> >>>>
> >>>> Is this a parenting issue?
> >>>>
> >>>> Thanks,
> >>>> Oszkar
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt-action-test.tar.gz
Type: application/x-compressed-tar
Size: 958 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100714/0dee449f/attachment.bin 


More information about the Qt-interest-old mailing list