PDA

View Full Version : QMenu and signals



mattia
20th December 2007, 08:02
Hello, i created a menu entry in this way:


QMenuBar *twmmenuBar;
twmmenuBar = new QMenuBar(twmMainWindow);

QMenu *menuTools;
menuTools = new QMenu(twmmenuBar);
menuTools->setObjectName(QString::fromUtf8("menuTools"));
twmmenuBar->addAction(menuTools->menuAction());
menuTools->setTitle(QApplication::translate("twmMainWindow", "Tools", 0, QApplication::UnicodeUTF8));

why this connections doesn't work?


connect ( ui.menuTools , SIGNAL ( triggered( QAction *) ) , this , SLOT ( mySlot QAction * ) ) );

I get this error:


error: ‘SIGNAL’ was not declared in this scope

i checked here
http://doc.trolltech.com/4.2/qmenu.html#triggered
and menuTools is QMenu Object and it should be able to emit the triggered( QAction *) signal.
My needs is throw a slot when menuTools is clicked.
thx

marcel
20th December 2007, 08:22
connect ( ui.menuTools , SIGNAL (triggered( QAction *) ) , this , SLOT(mySlot(QAction*) ) );

mattia
20th December 2007, 08:31
of course, you are right, i made a mistake with the keybord but in my code it's typed in the right way, like you suggest me up here.

marcel
20th December 2007, 08:34
Maybe you have a problem with you Qt installation and/or include paths.
Can you compile a simple Qt application?

mattia
20th December 2007, 08:52
When i try to add a enty in that menu i don't have problem, it works. It is just that signal that doesn't work...i think i have not problems with path or inclusion...

jpn
20th December 2007, 09:00
Do connections work elsewhere? The connection statement you pasted is out of context. Could you paste a larger block of code?

mattia
20th December 2007, 09:09
my fault.....it was a context error....thx for your hint! ;)