Results 1 to 2 of 2

Thread: SLOT or functions

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default SLOT or functions

    Hi,
    I'd code a SLOT in Mainform.ui (from Designer) and I the Connect in myWidget() class constructor.
    I call emit mySignal() and starts the SLOT in mainform.
    But I can make instead of "emit mySignal()" mainForm->function() (without signal). The result it's the same! and then, what do I use?
    Wich in the different?
    Thanks
    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SLOT or functions

    Signals & slots mechanism:
    • many-to-many connections,
    • you can connect and disconnect objects in the runtime,
    • connected objects doesn't have to know anything about each other.


    Direct method invocation:
    • many-to-one connection,
    • you must have a pointer or the object itself to invoke a method,
    • there is no way to disconnect those object without using conditional statements around the call,
    • a bit faster (although speed-up usually won't be noticeable).

    What to use depends on the design.

Similar Threads

  1. How to declare SLOT as a parameter to member function?
    By QPlace in forum Qt Programming
    Replies: 2
    Last Post: 17th July 2018, 01:41
  2. Replies: 12
    Last Post: 18th September 2008, 16:04
  3. Problem When Creating my own Slot
    By Fatla in forum Qt Programming
    Replies: 12
    Last Post: 6th June 2008, 15:44
  4. Replies: 2
    Last Post: 16th March 2007, 10:04

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.