Results 1 to 7 of 7

Thread: QMenu and signals

  1. #1
    Join Date
    Oct 2007
    Location
    Italy
    Posts
    172
    Thanks
    39
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QMenu and signals

    Hello, i created a menu entry in this way:
    Qt Code:
    1. QMenuBar *twmmenuBar;
    2. twmmenuBar = new QMenuBar(twmMainWindow);
    3.  
    4. QMenu *menuTools;
    5. menuTools = new QMenu(twmmenuBar);
    6. menuTools->setObjectName(QString::fromUtf8("menuTools"));
    7. twmmenuBar->addAction(menuTools->menuAction());
    8. menuTools->setTitle(QApplication::translate("twmMainWindow", "Tools", 0, QApplication::UnicodeUTF8));
    To copy to clipboard, switch view to plain text mode 
    why this connections doesn't work?
    Qt Code:
    1. connect ( ui.menuTools , SIGNAL ( triggered( QAction *) ) , this , SLOT ( mySlot QAction * ) ) );
    To copy to clipboard, switch view to plain text mode 
    I get this error:
    Qt Code:
    1. error: ‘SIGNAL’ was not declared in this scope
    To copy to clipboard, switch view to plain text mode 
    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

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMenu and signals

    Qt Code:
    1. connect ( ui.menuTools , SIGNAL (triggered( QAction *) ) , this , SLOT(mySlot(QAction*) ) );
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Oct 2007
    Location
    Italy
    Posts
    172
    Thanks
    39
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QMenu and signals

    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.

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMenu and signals

    Maybe you have a problem with you Qt installation and/or include paths.
    Can you compile a simple Qt application?

  5. The following user says thank you to marcel for this useful post:

    mattia (20th December 2007)

  6. #5
    Join Date
    Oct 2007
    Location
    Italy
    Posts
    172
    Thanks
    39
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QMenu and signals

    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...

  7. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QMenu and signals

    Do connections work elsewhere? The connection statement you pasted is out of context. Could you paste a larger block of code?
    J-P Nurmi

  8. The following user says thank you to jpn for this useful post:

    mattia (20th December 2007)

  9. #7
    Join Date
    Oct 2007
    Location
    Italy
    Posts
    172
    Thanks
    39
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QMenu and signals

    my fault.....it was a context error....thx for your hint!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.