Results 1 to 4 of 4

Thread: Signals and Slots querry -- urgent

  1. #1
    Join Date
    Jul 2007
    Posts
    25
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Signals and Slots querry -- urgent

    I've a question, although I know that, only member functions are used for implementing Singnals and Slots using connect(), is there any way to call /use a non-member function which has been already declared and defined in other file, related to the same application, as a SLOT using connect() ??

    Any help will appreciated in this regard.

    Thanks

  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: Signals and Slots querry -- urgent

    No. Signals/slots only work with classes that have the Q_OBJECT macro.
    The moc won't know hot to compile that code if you use an application static function.
    Why don't you make a wrapper for that function in a class? You know, create a method that calls the global function.

    Regards

  3. #3
    Join Date
    Jul 2007
    Posts
    25
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Signals and Slots querry -- urgent

    Quote Originally Posted by marcel View Post
    No. Signals/slots only work with classes that have the Q_OBJECT macro.
    The moc won't know hot to compile that code if you use an application static function.
    Why don't you make a wrapper for that function in a class? You know, create a method that calls the global function.

    Regards
    yeah I thought of that, but wanted to clear it with someone who knows Qt pretty well. And your suggestion for writting a wrapper is very valid point and I was actually going to do the same, if there wouldn't have been any other way for calling a non-member static function through Signals/Slot mechanism.
    It will be helpful if somebody do come up with something like that wrapper function, which calls a static function, when Signals and Slots are connected.

    I suppose I may get back to it soon.

    Thanks

  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: Signals and Slots querry -- urgent

    It will be helpful if somebody do come up with something like that wrapper function, which calls a static function, when Signals and Slots are connected.
    I don't know about that.
    I suppose one could make this more general using pointers to functions (or even lambda functions if they ever become available).

    But this is basically a simple process of just calling one function and everybody just adds wrappers. It is just like calling a function from an external non-Qt library as response to a signal.

    Regards

Similar Threads

  1. Signals and Slots question
    By Thoosle in forum Qt Programming
    Replies: 5
    Last Post: 5th December 2006, 00:24
  2. Nested signals and slots
    By vishva in forum Qt Programming
    Replies: 2
    Last Post: 18th August 2006, 09:47
  3. Signals and Slots in dll
    By ankurjain in forum Qt Programming
    Replies: 8
    Last Post: 29th March 2006, 08:12
  4. Order of signals and slots
    By Morea in forum Newbie
    Replies: 1
    Last Post: 26th February 2006, 22:09
  5. Problem with Signals and Slots
    By Kapil in forum Newbie
    Replies: 11
    Last Post: 15th February 2006, 11:35

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.