Results 1 to 3 of 3

Thread: Can a signal connect to a slot which in other file?

  1. #1
    Join Date
    Sep 2010
    Posts
    7
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Lightbulb Can a signal connect to a slot which in other file?

    Hello!I am a new.In my program,I got a problem.I have a slot in one *.cpp file,and a signal in another *.cpp file.How can I use this signal to connect to that slot?If it can be done.I hope you can give a example code.Thanks very much.

  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: Can a signal connect to a slot which in other file?

    Connections are done between objects.

    If you have class A in file a.cpp and class B in file b.cpp:

    Qt Code:
    1. A *a = new A;
    2. B *b = new B;
    3.  
    4. connect(a, SIGNAL(...), b, SLOT(...));
    To copy to clipboard, switch view to plain text mode 

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

    brantyou (15th September 2010)

  4. #3
    Join Date
    Sep 2010
    Posts
    7
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Can a signal connect to a slot which in other file?

    Thanks for your help very much ! I do that. You are right! Because your help,I have known something that unknown before.

Similar Threads

  1. Can't connect a signal to a slot
    By cejohnsonsr in forum Newbie
    Replies: 5
    Last Post: 26th August 2010, 21:42
  2. How to connect signal/slot in QItemEditorFactory?
    By yyalli in forum Qt Programming
    Replies: 1
    Last Post: 4th June 2010, 15:56
  3. problem connect signal - slot
    By jaca in forum Newbie
    Replies: 13
    Last Post: 9th March 2010, 20:38
  4. qt signal/slot auto-connect issue
    By parnedo in forum Qt Programming
    Replies: 9
    Last Post: 16th July 2009, 13:55
  5. A signal/slot connect isn't working.
    By Daimonie in forum Qt Programming
    Replies: 6
    Last Post: 15th February 2009, 23:55

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.