Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, April 2007
is it possible to add a QCheckBox to a QMenuBar ?


Message 1 in thread

hi, everyone
i just want to add a few qcheckbox to a qmenubar, is it possible ? maybe it
hears stupid. aha...
qmenubar doesn't have addWidget() function , just addMenu(), addAction()
,ect.
regards
fengli

Message 2 in thread

Menu items (QAction) are already checkable. You do not need a QCheckBox to
check/uncheck a menu item.

Look at QAction::setCheckable(bool) and QAction::setChecked(bool) (slot).

Keith

On 04-16-2007 8:17 AM, "张凤丽" wrote:

> hi, everyone 
> i just want to add a few qcheckbox to a qmenubar, is it possible ? maybe it
> hears stupid. aha...
> qmenubar doesn't have addWidget() function , just addMenu(), addAction() ,ect.
> regards
> fengli
> 


Message 3 in thread

hi,
i mean i want a checkbox in a menubar, not in a menu.
regards
fengli

2007/4/17, Keith Esau <keith.esau@xxxxxxx>:
>
>  Menu items (QAction) are already checkable. You do not need a QCheckBox
> to check/uncheck a menu item.
>
> Look at QAction::setCheckable(bool) and QAction::setChecked(bool) (slot).
>
> Keith
>
> On 04-16-2007 8:17 AM, "张凤丽" wrote:
>
> hi, everyone
> i just want to add a few qcheckbox to a qmenubar, is it possible ? maybe
> it hears stupid. aha...
> qmenubar doesn't have addWidget() function , just addMenu(), addAction()
> ,ect.
> regards
> fengli
>
>

Message 4 in thread

Ah, I believe I understand what you want, but I would recommend against it.
I haven't ever seen anything like that on any platform. On the Mac, in
particular, the menu bar is not at all like a tool bar. Menus are at the top
of the screen and outside the main window, not inside.

You could mimic what you are suggesting by using a tool bar that consists
mostly of pop-down menus and your check box. But on the Mac, it wouldn't be
where menu bars are supposed to go.


On 04-16-2007 7:34 PM, "张凤丽" wrote:

> hi,
> i mean i want a checkbox in a menubar, not in a menu.
> regards
> fengli
> 
> 2007/4/17, Keith Esau <keith.esau@xxxxxxx>:
>> Menu items (QAction) are already checkable. You do not need a QCheckBox to
>> check/uncheck a menu item.
>> 
>> Look at QAction::setCheckable(bool) and QAction::setChecked(bool) (slot).
>> 
>> Keith
>> 
>> 
>> On 04-16-2007 8:17 AM, "张凤丽" wrote:
>> 
>>> hi, everyone 
>>> i just want to add a few qcheckbox to a qmenubar, is it possible ? maybe it
>>> hears stupid. aha...
>>> qmenubar doesn't have addWidget() function , just addMenu(), addAction()
>>> ,ect.
>>> regards
>>> fengli
>>> 


Message 5 in thread

Keith Esau wrote:
> Ah, I believe I understand what you want, but I would recommend against 
> it. I haven't ever seen anything like that on any platform. On the Mac, 
> in particular, the menu bar is not at all like a tool bar. Menus are at 
> the top of the screen and outside the main window, not inside.
> 
> You could mimic what you are suggesting by using a tool bar that 
> consists mostly of pop-down menus and your check box. But on the Mac, it 
> wouldn't be where menu bars are supposed to go.
> 
> 
> On 04-16-2007 7:34 PM, "张凤丽" wrote:
> 
>     hi,
>     i mean i want a checkbox in a menubar, not in a menu.
>     regards
>     fengli
> 
>     2007/4/17, Keith Esau <keith.esau@xxxxxxx>:
> 
>         Menu items (QAction) are already checkable. You do not need a
>         QCheckBox to check/uncheck a menu item.
> 
>         Look at QAction::setCheckable(bool) and
>         QAction::setChecked(bool) (slot).
> 
>         Keith
> 
> 
>         On 04-16-2007 8:17 AM, "张凤丽" wrote:
> 
>             hi, everyone
>             i just want to add a few qcheckbox to a qmenubar, is it
>             possible ? maybe it hears stupid. aha...
>             qmenubar doesn't have addWidget() function , just addMenu(),
>             addAction() ,ect.
>             regards
>             fengli
> 
The standard way to do this is to add a toolbar below the menubar. You
then add actions to the toolbar. These actions can also be added to menus.

--
 [ signature omitted ]