Results 1 to 2 of 2

Thread: “Pass” slots from class to class

  1. #1
    Join Date
    May 2007
    Posts
    131
    Thanks
    17
    Thanked 4 Times in 2 Posts

    Default “Pass” slots from class to class

    Hello,


    I am currently struggeling with what is the best way to pass slots from the outer class to a class instance within it.
    My problem is, that i have plenty of signals beeing emmitted by the inner class and it is quite easy to pass the signals on,
    but how do i handle the slots? Is there any good way to pass them on, without having to do the following:

    Qt Code:
    1. //Slot in the outer class
    2. void outerClass::someSlot()
    3. {
    4. myInnerClass->someSlot();
    5. }
    To copy to clipboard, switch view to plain text mode 

    Thank you in advance.

  2. #2
    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: “Pass” slots from class to class

    You have many options:
    1) Call the slot manually (like your example)
    2) You can connect multiple slots to the same signal: Connect both (all) slots to the signal that is connected to the outerClass::someSlot
    3) You can connect signal to signal: Create a signal "chain": add a signal into outerClass this signal connect it to both (/all the slots you need) slots and connect the outside signal to this signal.

    So you can choose depending on what works best in your project.

Similar Threads

  1. Replies: 2
    Last Post: 26th July 2015, 15:38
  2. Signals Slots and Class Pointers
    By Atomic_Sheep in forum Newbie
    Replies: 18
    Last Post: 7th September 2012, 09:08
  3. Pure virtual class with singals and slots
    By rubikon in forum Newbie
    Replies: 2
    Last Post: 31st August 2012, 10:32
  4. Access a class without using Signals/Slots
    By impeteperry in forum Qt Programming
    Replies: 5
    Last Post: 10th January 2010, 11:14
  5. function 'connect' always look super class for slots.
    By Intaek Lim in forum Qt Programming
    Replies: 7
    Last Post: 12th March 2007, 13:38

Tags for this Thread

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.