Results 1 to 3 of 3

Thread: Is there any way to convert a generic function to slot ?

  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Is there any way to convert a generic function to slot ?

    I'd want to write something like this

    connect (a,signal(a),this, convert_to_slot(my_function))

    Fiction science ?
    Thanks

  2. #2
    Join Date
    Aug 2010
    Posts
    107
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Is there any way to convert a generic function to slot ?

    Why not declare my_function as a slot? You can still call it in a normal way.

  3. #3
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Is there any way to convert a generic function to slot ?

    Or, if the function is not your code, create your own slot, connect the signal to that slot, and within that slot call the function.
    Qt Code:
    1. //slot definition
    2. void THIS_CLASS::my_slot(...) {
    3. my_function(...); //call my_function
    4. }
    5. //connection
    6. connect (a,signal(...),this, my_slot(...))
    To copy to clipboard, switch view to plain text mode 

  4. The following user says thank you to Zlatomir for this useful post:

    tonnot (19th April 2011)

Similar Threads

  1. Function to convert std::string to QString
    By ogward in forum Qt Programming
    Replies: 6
    Last Post: 9th April 2011, 13:46
  2. Replies: 3
    Last Post: 23rd December 2010, 01:01
  3. My Slot Function
    By qtoptus in forum Qt Programming
    Replies: 3
    Last Post: 3rd November 2010, 17:38
  4. Why do i need to declare a function as a slot?
    By cbarmpar in forum Qt Programming
    Replies: 2
    Last Post: 31st August 2008, 21:38
  5. slot control of new function
    By tommy in forum Qt Programming
    Replies: 3
    Last Post: 11th November 2007, 04:58

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.