Results 1 to 2 of 2

Thread: Accessing slots of other classes

  1. #1
    Join Date
    Jan 2011
    Posts
    55
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Accessing slots of other classes

    Sorry if this is a newbie question: I've searched the forum and googled, but could not find any informations about it.
    I have a project organized in 3 c++ (plus headers):

    - main.cpp
    - child1.cpp
    - child2.cpp

    I was wondering if there is a way, for widgets in child1.cpp, to connect access slots in child2.cpp

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Accessing slots of other classes

    You need to create objects and then connect the objects.
    You can not connect classes directly.

    example:
    Qt Code:
    1. MyClass1 objectOfTypeMyClass1;
    2. MyClass2 *pointerToAnObjectOfMyClass2 = new MyClass2;
    3.  
    4. connect(&objectOfTypeMyClass1, SIGNAL(someSignal()), pointerToAnObjectOfMyClass2, SLOT(someSlot()));
    To copy to clipboard, switch view to plain text mode 

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

    papillon (14th January 2011)

Similar Threads

  1. Replies: 5
    Last Post: 17th November 2010, 17:29
  2. Signals/slots between classes
    By been_1990 in forum Qt Programming
    Replies: 19
    Last Post: 27th November 2009, 13:04
  3. Accessing "log-class" from other classes
    By darksaga in forum Qt Programming
    Replies: 6
    Last Post: 23rd May 2007, 22:31
  4. signal/slots in template classes
    By killkolor in forum Qt Programming
    Replies: 2
    Last Post: 6th December 2006, 18:28
  5. Signals and Slots between 2 classes
    By probine in forum Qt Programming
    Replies: 1
    Last Post: 31st March 2006, 00:34

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.