Results 1 to 2 of 2

Thread: Context menu / connect with parameters

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2009
    Location
    England & Italy
    Posts
    1
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Context menu / connect with parameters

    I have a problem with context menus. I would like to create one in a dynamic way, i.e. passing a set of string variables:

    Qt Code:
    1. void MyClass::contextMenu(std::vector<QAction*>& labelsAct)
    2. {
    3. for(size_t i = 0; i < labelsAct.size(); ++i)
    4. {
    5. QObject::connect(labelsAct[i], SIGNAL(mySignal(int)),
    6. this, SLOT(doSomething(int)));
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

    This is the message I get at runtime:

    Qt Code:
    1. Object::connect: No such signal QAction::mySignal(int)
    To copy to clipboard, switch view to plain text mode 

    doSomething(int) is defined in the MyClass class.
    mySignal(int) is declared in the MyClass class; why does it look for the signal in QAction?

    If I remove the int parameters from those function (definitions), the connect works correctly. But I need those parameters.

    Thank you...
    Last edited by pietrom; 18th February 2009 at 17:54.

Similar Threads

  1. Context Menu on QTableWidget
    By ankurjain in forum Qt Programming
    Replies: 9
    Last Post: 17th December 2009, 09:52
  2. Shortcut key for context menu
    By darshan.hardas in forum Qt Programming
    Replies: 1
    Last Post: 28th December 2008, 20:32
  3. QItemDelegate Context Menu
    By aekilic in forum Qt Programming
    Replies: 16
    Last Post: 3rd December 2008, 09:29
  4. context menu problem
    By dreamer in forum Qt Programming
    Replies: 1
    Last Post: 25th May 2008, 13:18
  5. Replies: 4
    Last Post: 25th June 2007, 20:40

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.