Results 1 to 5 of 5

Thread: QObject signal/slot not working

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2009
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default QObject signal/slot not working

    I have a class A that inherits QWidget and class B that inherits QObject.

    When a button is clicked, class A creates an object of Class B. Class B is supposed to perform a http request and emit a done signal to perform the slot function.

    The problem is that class B can initialize properly but it cannot execute the slot function when the done signal is emitted. As far as I know, I don't see debug errors and my actual code is a bit too long.

    Example:

    Qt Code:
    1. class A : public QWidget
    2. {
    3. Q_OBJECT
    4. public:
    5. A();
    6. private slots;
    7. void buttonClicked();
    8. private:
    9. QPushButton *button;
    10. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. class B : public QObject
    2. {
    3. Q_OBJECT
    4. public:
    5. B();
    6. private slots;
    7. void performFunction();
    8. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. A::A()
    2. {
    3. ...
    4. connect(button,SIGNAL(clicked()),this,SLOT(buttonClicked()));
    5.  
    6. void A::buttonClicked()
    7. {
    8. B objectB;
    9. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. B::B()
    2. {
    3. ...
    4. connect(http,SIGNAL(done(bool)),this,SLOT(performFunction()));
    5. }
    To copy to clipboard, switch view to plain text mode 

    Could anyone point out what I have done wrong.
    Last edited by Msnforum; 24th January 2009 at 21:02.

Similar Threads

  1. QObject and copy Constructors
    By December in forum Qt Programming
    Replies: 5
    Last Post: 17th July 2008, 16: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
  •  
Qt is a trademark of The Qt Company.