Important: Please read the Qt Code of Conduct -

Confusion about signals/slots

  • Hey,

    I am very new to Qt and this question will have probably already been answered a dozen times (although I cannot find it). The program I'm writing basically creates a QDockWidget of which I want to connect the visibilityChanged(bool) signal to a custom slot that then checks/unchecks a menu item. It all works as I expect the problem I'm having is I get the error message

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

    And I don't really understand what the problem is since it is working correctly.

    In mainwindow.h I declare:

    private slots:
        void on_actionFirstDock_visibilityChanged(bool visible);


     MainWindow::MainWindow(QWidget *parent) :
         ui(new Ui::MainWindow){
         firstDock = new QDockWidget(this);
     void MainWindow::on_actionFirstDock_visibilityChanged(bool visible){

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    That's because you named your slot the same way as is expected for the auto connection feature.

    Just remove the underscores (and make it full camelcase for easier reading) and you should be good to go.

  • Lifetime Qt Champion

    as a note , you might want to know about the new syntax
    Its better than the SIGNAL/SLOT macros as it fails compile time and not
    run time if something is not right.

Log in to reply