Results 1 to 3 of 3

Thread: How to decide which SIGNAL to emit?

  1. #1
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default How to decide which SIGNAL to emit?

    I have a joystick reader program. When a button of the joystick is pressed, a signal needs to be emitted.

    How to choose which signal needs to be emitted?
    Is there a list of the signals somewhere?

  2. #2
    Join Date
    Apr 2010
    Location
    Russian Federation, Kaluga
    Posts
    20
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to decide which SIGNAL to emit?

    Hi, Anisha.
    You can provide you own signal and appropriate slot for it.
    For example
    Qt Code:
    1. class CJoistikReader : public QObject
    2. {
    3. Q_OBJECT
    4. public:
    5. CJoistikReader(QObject*parent=0);
    6. signals:
    7. //you can emmit this signal, with button's id when appropriate button of joystik is pressed
    8. void evButtonPressed(int button_id);
    9. //-------- other methods and members of class -----
    10. };
    11.  
    12. class CJoistikSignalReciver : public QObject
    13. {
    14. Q_OBJECT
    15. public:
    16. CJoistikSignalReciver(QObject*parent=0);
    17. public slots:
    18. // connect this slot to CJoistikReader::evButtonPressed(int) signal and process pressing
    19. void processPressingButton(int button_id);
    20. //-------- other methods and members of class -----
    21. };
    To copy to clipboard, switch view to plain text mode 

    In QtGui model (though QApplication eventLoop) EVENTs (not signals) sending during about keyboadr and mouse manipulating (EKeyPressEvent, EMousePressEvent and so on). See QWidget documentation.

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

    TheIndependentAquarius (17th July 2014)

  4. #3
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    131
    Thanks
    11
    Thanked 16 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to decide which SIGNAL to emit?

    For each QObject class in Qt the signals are listed in the API, but you can always define as much custom signals as you want. Who is the receiver object of you signal? What should happen after the button press?

  5. The following user says thank you to nightghost for this useful post:

    TheIndependentAquarius (17th July 2014)

Similar Threads

  1. Replies: 2
    Last Post: 3rd May 2011, 21:22
  2. emit signal from a slot?
    By ask8y@yahoo.com in forum Qt Programming
    Replies: 9
    Last Post: 11th June 2010, 21:18
  3. Emit signal from thread
    By sisco in forum Newbie
    Replies: 2
    Last Post: 26th November 2009, 14:32
  4. how to know which button emit the signal?
    By coder1985 in forum Qt Programming
    Replies: 2
    Last Post: 12th January 2008, 15:26
  5. emit a signal
    By Morea in forum Qt Programming
    Replies: 2
    Last Post: 27th February 2006, 12:14

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.