Results 1 to 2 of 2

Thread: slots with params problem

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

    Question slots with params problem

    I want to send a signal which with params to a slot. And the params is necessary to the slot.For example,mysignal(int , QString); myslot(int , QString). If I used the slot like that,whether it is right or not. My mind is to inform a slot function, and pass the param to it.

    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: slots with params problem

    I don't understand your question.

    But here's an example of a signal and slot connection with parameters:

    Qt Code:
    1. Class A : public QObject
    2. {
    3. Q_OBJECT
    4.  
    5. signals:
    6. void signalWithParameters(const QString &text, int number);
    7. };
    8.  
    9. Class B: public QObject
    10. {
    11. Q_OBJECT
    12.  
    13. public slots:
    14. void slotWithParameters(const QString &text, int number);
    15. };
    16.  
    17. ...
    18.  
    19. A aObject;
    20. B bObject;
    21. connect(&aObject, SIGNAL(signalWithParameters(const QString&, int)), &bObject, SLOT(slotWithParameters(const QString&, int)));
    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)

Similar Threads

  1. Qt as only Gui Module (QMainWindow Params)
    By radex99 in forum Qt Programming
    Replies: 4
    Last Post: 30th August 2010, 19:13
  2. Problem with signals & slots
    By Palmik in forum Qt Programming
    Replies: 4
    Last Post: 17th January 2009, 23:45
  3. signals and slots problem
    By sonuani in forum Newbie
    Replies: 6
    Last Post: 26th November 2008, 18:00
  4. problem with slots
    By babu198649 in forum Newbie
    Replies: 8
    Last Post: 31st March 2008, 12:50
  5. Signals And Slots problem
    By ldiamond in forum Newbie
    Replies: 7
    Last Post: 23rd March 2008, 01:11

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.