Qt-interest Archive, May 2008
Number of menus in the menubar
Message 1 in thread
Hi,
Is there a way to determine the number of menus in the menubar?
For example: If the menubar was "File Edit View Help" I need to know
there are 4 menus.
I do not create the menus so I cannot count them when created.
Thanks.
Don
Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
Message 2 in thread
Hi,
"Kellmel, Don" <Don.Kellmel@xxxxxxxxxxxxxx> schreef in bericht news:A7B7114CC4C6A24E83ACF3A8C5B58CE774A4D5@xxxxxxxxxxxxxxxxxxxxxx
Is there a way to determine the number of menus in the menubar?
For example: If the menubar was "File Edit View Help" I need to know there are 4 menus.
I do not create the menus so I cannot count them when created.
------------------------------------------------------------------------------
I would try to iterate over the QMenuBar's children and find the QMenu's in there. That should work, I guess. Alternatively, you could try looking into QWidget::actions(), and see if that yields anything usefull. Note that I did not try either method myself.
HTH,
André
Message 3 in thread
Thanks AndrÃ,
The following worked:
QList<QMenu *> allMenus = menubar->findChildren<QMenu *>();
std::cout << allMenus.count() << std::endl;
for(int i=0; i<allMenus.count(); i++)
{
//menubar->removeAction(allMenus.at(i)->menuAction());
}
This gave me a list of menus prior to me adding to it. I could then add another list and switch between them.
Don
________________________________
From: Andrà Somers [mailto:andre@xxxxxxxxxxxxxxxx]
Sent: Wednesday, May 14, 2008 3:26 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: Re: Number of menus in the menubar
Hi,
"Kellmel, Don" <Don.Kellmel@xxxxxxxxxxxxxx> schreef in bericht news:A7B7114CC4C6A24E83ACF3A8C5B58CE774A4D5@xxxxxxxxxxxxxxxxxxxxxx
Is there a way to determine the number of menus in the menubar?
For example: If the menubar was "File Edit View Help" I need to know there are 4 menus.
I do not create the menus so I cannot count them when created.
________________________________
I would try to iterate over the QMenuBar's children and find the QMenu's in there. That should work, I guess. Alternatively, you could try looking into QWidget::actions(), and see if that yields anything usefull. Note that I did not try either method myself.
HTH,
AndrÃ
Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
Message 4 in thread
You could also try and use the aboutToShow signal on the menus themselves.. And create the actions going in at that point.
Scott
From: Kellmel, Don [mailto:Don.Kellmel@xxxxxxxxxxxxxx]
Sent: Wednesday, May 14, 2008 1:01 PM
To: Andrà Somers; qt-interest@xxxxxxxxxxxxx
Subject: RE: Number of menus in the menubar
Thanks AndrÃ,
The following worked:,
QList<QMenu *> allMenus = menubar->findChildren<QMenu *>();
std::cout << allMenus.count() << std::endl;
for(int i=0; i<allMenus.count(); i++)
{
//menubar->removeAction(allMenus.at(i)->menuAction());
}
This gave me a list of menus prior to me adding to it. I could then add another list and switch between them.
Don
________________________________
From: Andrà Somers [mailto:andre@xxxxxxxxxxxxxxxx]
Sent: Wednesday, May 14, 2008 3:26 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: Re: Number of menus in the menubar
Hi,
"Kellmel, Don" <Don.Kellmel@xxxxxxxxxxxxxx> schreef in bericht news:A7B7114CC4C6A24E83ACF3A8C5B58CE774A4D5@xxxxxxxxxxxxxxxxxxxxxx
Is there a way to determine the number of menus in the menubar?
For example: If the menubar was âFile Edit View Helpâ I need to know there are 4 menus.
I do not create the menus so I cannot count them when created.
________________________________
I would try to iterate over the QMenuBar's children and find the QMenu's in there. That should work, I guess. Alternatively, you could try looking into QWidget::actions(), and see if that yields anything usefull. Note that I did not try either method myself.
HTH,
AndrÃ
________________________________
Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
________________________________
Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.