Important: Please read the Qt Code of Conduct -

QMetaObject problem with QPushButton connection

  • In the .h file for my class, I define a QPushButton as well as the function that will be called. It looks like this:

    private slots:
    void on_bubbleTypeButton_clicked();

    QPushButton *bubbleTypeButton;

    Then in the constructor for the class, I create the button with this code:

    bubbleTypeButton = new QPushButton(this);
    bubbleTypeButton->setGeometry(400, 168, 250, 40);
    connect(bubbleTypeButton, SIGNAL(clicked()), this, SLOT(on_bubbleTypeButton_clicked()));

    The code compiles fine, but when I run the code, I get the following message:
    QMetaObject::connectSlotsByName: No matching signal for on_bubbleTypeButton_clicked()

    When I click the button, the on_bubbleTypeButton_clicked function runs, but obviously I don't want the error message. What did I miss?

  • Lifetime Qt Champion

    hi and welcome
    Qt has a auto connect feature that trigger via naming. on_widgetname_signal syntax.
    Since you are using a manual connect, please try to rename
    slot so its not on_xxx syntax.
    Then clean build folder.
    run qmake
    and rebuild all.
    That normally shut it up :)

  • Yes, that did it. Thanks

Log in to reply