[Qt-interest] Menu bar on QtCreator created GUI

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Tue Jul 13 17:28:31 CEST 2010


OS Prog wrote on Tuesday, July 13, 2010 4:12 PM:

> I've created a GUI with the Qt Creator and I've put some items under
> the Menu Bar. On the QtCreator Designer window it looks OK, 

What do you mean by "it looks OK"? Does something happen (besides that the menu disappears, as I ASSUME)?

> but when
> I run the application the items are not click-able. They are not
> disabled (grayed out), but when I click on them nothing happened.

Well, what do you EXPECT to happen?  Why do you expect something to happen at all (again, I ASSUME the menu disappears once you click an item)? Simply adding menu items in the GUI editor (the embedded "Qt Designer, to be specific) does not associate them with any behaviour. Or did you connect some signal/slots in the Qt Designer, too?

> Do I have to set something in order to make them working?

Off course, you have to actually connect the QActions (the "menu items") to some slot, either by following some naming convention (fragile when renaming/refactoring!) like

  on_fooAction_triggered() {.... // here goes your actual "what should happen" logic ...}

and the like or you explicitly connect the corresponding QActions in your code.

(Unfortunatelly Qt does not yet implement the "DoWhatIMeanAndDoItAutomagically"-technology - this is planned in an upcoming Qt release, but no promises made for Qt 5.0!)


You might want to read about Qt signal/slots first: http://doc.trolltech.com/4.6/signalsandslots.html

Cheers, Oliver
-- 
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22



More information about the Qt-interest-old mailing list