Results 1 to 3 of 3

Thread: Double the signals, double the fun! ...or not in my case...

  1. #1
    Join Date
    Apr 2009
    Posts
    19
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Wink Double the signals, double the fun! ...or not in my case...

    Hello,

    I have a form with a few widgets.

    When a button is pressed the form calls a function, that is pretty much it. However, whenever I click the button the on_clicked slot is called twice.

    I know this is the case because in trying to track down the source of the problem of multiple messages from my little program I put a break point on the function inside the on_clicked slot, and sure enough, I click the button and it is reached twice in quick succession.

    Qt Code:
    1. #include "generatedfiles/ui_form.h"
    2.  
    3. void send_msg(char* );
    4. void reconnect();
    5.  
    6. class formui : public QWidget, public Ui::Form
    7. {
    8. Q_OBJECT
    9. public:
    10. formui(QWidget* parent = 0) : QWidget(parent) {
    11. setupUi(this);
    12. QMetaObject::connectSlotsByName(this);
    13. }
    14.  
    15. public slots:
    16. void on_pushButton_clicked()
    17. {
    18. send_msg( lineEdit->toPlainText().toUtf8().data() );
    19. }
    20.  
    21. void on_pushButton_2_clicked()
    22. {
    23. reconnect();
    24. }
    25. };
    To copy to clipboard, switch view to plain text mode 

    That above is from my forms header file, that really is it! How can it be going wrong?

    PS. It seems both the buttons slots are called twice.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Double the signals, double the fun! ...or not in my case...

    Skip
    Qt Code:
    1. QMetaObject::connectSlotsByName(this);
    To copy to clipboard, switch view to plain text mode 
    the setupUi does that automatically!

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

    sebastian.f (24th June 2009)

  4. #3
    Join Date
    Apr 2009
    Posts
    19
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Thumbs up Re: Double the signals, double the fun! ...or not in my case...

    Ah ha!
    Dont I look stupid now

    Thanks Lykurg!

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.