Results 1 to 2 of 2

Thread: Connecting signal and slot by name

  1. #1
    Join Date
    May 2011
    Posts
    46
    Thanks
    5

    Default Connecting signal and slot by name

    I am currently using this code to connect them by name and it actually works, is this the supported way of doing so?

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication app(argc, argv);
    4. b.show();
    5.  
    6. // connect
    7. b.connect(&b, "2clicked()", &app, "1quit()");
    8.  
    9. // disconnect
    10. b.disconnect(&app, "1quit()");
    11.  
    12. return app.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 

    The reason I am doing this is because I want to be able to save/load actions using xml file.

  2. #2
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Connecting signal and slot by name

    SIGNAL and SLOT are macros which convert argument to string with prefix, so you just resolved those macros. It is recommended to use macros (easy to read and ease to maintain code, for example in Qt Creator code completion or renaming of method will work only with macro).

Similar Threads

  1. Replies: 3
    Last Post: 17th November 2010, 14:12
  2. Replies: 8
    Last Post: 13th July 2010, 14:08
  3. Replies: 2
    Last Post: 9th September 2009, 00:26
  4. Connecting signal to custom slot?
    By dbrmik in forum Qt Tools
    Replies: 2
    Last Post: 30th April 2009, 09:28
  5. Connecting to a slot not within an Obejct
    By Matze-o in forum Qt Programming
    Replies: 2
    Last Post: 10th November 2008, 14:02

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.