Results 1 to 2 of 2

Thread: signal from QMetaMethod

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2007
    Location
    Philadelphia, USA
    Posts
    255
    Thanks
    43
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default signal from QMetaMethod

    I need to connect a signal retrieved from QMetaMethod::signature(). There doesn't seem to be a Qt function to achieve this, so I had a look at the SIGNAL macro, and so this is what I do (basically stick a "2" in front of the signature):

    Qt Code:
    1. QMetaMethod mymethod=...;
    2. char holdstr[1000];
    3. sprintf(holdstr,"2%s",mymethod.signature());
    4. connect(obj,holdstr,this,SLOT(myslot()));
    To copy to clipboard, switch view to plain text mode 

    It's a hack and I don't like it -- not even sure it will work all the time. Is there a better way to achieve this?

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: signal from QMetaMethod

    It's fine, though using sprintf in no the best way to get that string You could manipulate the meta object directly but the result would be the same, so it's not worth it.

  3. The following user says thank you to wysota for this useful post:

    magland (14th June 2007)

Similar Threads

  1. how to emit signal in a static function ?
    By cxl2253 in forum Qt Programming
    Replies: 32
    Last Post: 7th July 2016, 21:36
  2. Replies: 3
    Last Post: 15th April 2007, 19:16
  3. Replies: 2
    Last Post: 17th May 2006, 21:01
  4. no such signal QListBox::currentChanged()
    By jopie bakker in forum Newbie
    Replies: 2
    Last Post: 2nd March 2006, 15:17
  5. send signal from QCombobox
    By raphaelf in forum Qt Programming
    Replies: 22
    Last Post: 28th February 2006, 14:18

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.