Results 1 to 6 of 6

Thread: Who can teach me how to creat a new SIGNAL or a SLOT using Qt creator?Yes I'm a pupil

  1. #1
    Join Date
    Jul 2011
    Location
    China Hunan province
    Posts
    7
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Smile Who can teach me how to creat a new SIGNAL or a SLOT using Qt creator?Yes I'm a pupil

    I just know how to write the code,but I don't know how to let them work.Who can tell me how to creat them with Qt Creator?

  2. #2
    Join Date
    May 2010
    Location
    Rousse, Bulgaria
    Posts
    25
    Thanks
    9
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Who can teach me how to creat a new SIGNAL or a SLOT using Qt creator?Yes I'm a p

    There's a fine example in the docs ( and online here ).

    Here's an example (not a 100% working example):
    in the header:
    Qt Code:
    1. #include <QtGui>
    2.  
    3. class MyClass : public QWidget
    4. {
    5. Q_OBJECT
    6. public:
    7. MyClass::MyClass();
    8. MyClass::~MyClass();
    9. signals:
    10. void mySig();
    11. public slots:
    12. void mySlot();
    13. };
    To copy to clipboard, switch view to plain text mode 
    and the cpp file:

    Qt Code:
    1. #include "myclass.h"
    2.  
    3. MyClass::MyClass() {
    4. .....
    5. connect (this, SIGNAL(mySig()), this, SLOT(mySlot());
    6. .....
    7. if (something) { emit mySig(); }
    8. }
    9.  
    10. MyClass::~MyClass()
    11. {
    12. }
    13.  
    14. void MyClass::MySlot()
    15. {
    16. .....
    17. doSomething();
    18. .....
    19. }
    To copy to clipboard, switch view to plain text mode 

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

    Dave2011 (5th August 2011)

  4. #3
    Join Date
    Jul 2011
    Location
    China Hunan province
    Posts
    7
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Who can teach me how to creat a new SIGNAL or a SLOT using Qt creator?Yes I'm a p

    And then? complie?


    Added after 16 minutes:


    I'm sorry I haven't understood.More detail please.Thanks!
    Last edited by Dave2011; 5th August 2011 at 17:01.

  5. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Who can teach me how to creat a new SIGNAL or a SLOT using Qt creator?Yes I'm a p

    Whats wrong with the great Signals And Slots documentation (A Small Example is available there as well) ?

  6. #5
    Join Date
    Jul 2011
    Location
    China Hunan province
    Posts
    7
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Who can teach me how to creat a new SIGNAL or a SLOT using Qt creator?Yes I'm a p

    I'm not good at English, you know,it's always a pity for me.I can't understand the documentation accuratly!
    What I'm needed is a whole example and the steps to complie it!
    Thanks to you for help me.

  7. #6
    Join Date
    Aug 2011
    Location
    Denmark
    Posts
    11
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: Who can teach me how to creat a new SIGNAL or a SLOT using Qt creator?Yes I'm a p

    For a simple signal/slot example you might take a look at this tread. The code in the post actually works.

    Start by making a new "Qt Quick Application" in Qt Creator.

Similar Threads

  1. plz teach inheritance
    By vinayaka in forum Newbie
    Replies: 10
    Last Post: 28th May 2011, 17:19
  2. Replies: 2
    Last Post: 3rd May 2011, 20:22
  3. Signal and slot in Creator
    By poporacer in forum Newbie
    Replies: 2
    Last Post: 27th September 2010, 23:48
  4. Signal connected to slot (or signal)
    By Althor in forum Newbie
    Replies: 2
    Last Post: 6th July 2010, 10:00
  5. signal slot conection using a string, not a SLOT
    By rianquinn in forum Qt Programming
    Replies: 6
    Last Post: 5th February 2006, 18:52

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.