Results 1 to 2 of 2

Thread: Avoid QMetaObject::connectSlotsByName warning

  1. #1
    Join Date
    May 2012
    Posts
    99
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question Avoid QMetaObject::connectSlotsByName warning

    Hi,

    I've added an optional parameter in the the on_pushButton_clicked() SLOT. The related code:

    Qt Code:
    1. private slots:
    2. void on_pushButton_clicked(bool isFree = false);
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void myClass::on_pushButton_clicked(bool isFree)
    2. {
    3. if (isFree)
    4. {
    5. // Do something
    6. }
    7. else
    8. {
    9. // Do something for not free
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 

    The code works well but I get the next warning:

    QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked(bool)

    Is it possible make some changes to avoid this warning?

    Regards.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Avoid QMetaObject::connectSlotsByName warning

    The most obvious solution is to avoid connect by name and use real connects.
    Has the added benefit of getting an error at compile time when a sender's name is changed instead of the program stopping to work correctly.

    I have never understood why anyone would want to use the connect by name feature.

    Cheers,

Similar Threads

  1. Replies: 7
    Last Post: 28th November 2013, 05:03
  2. How to avoid "warning: deprecated conversion from"?
    By Caius Aérobus in forum Qt Programming
    Replies: 3
    Last Post: 18th January 2011, 15:11
  3. connectSlotsByName isn't working
    By scarleton in forum Newbie
    Replies: 1
    Last Post: 9th October 2010, 12:52
  4. connectSlotsByName and clicked()
    By becrux in forum Qt Programming
    Replies: 5
    Last Post: 2nd December 2009, 07:05
  5. Replies: 2
    Last Post: 8th November 2007, 20:23

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.