Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

public slots: - not always works?



  • I have

    class ConfigDialog : public QDialog
    {
        void keyPressEvent(QKeyEvent *event);
        QLineEdit *syntaxPath;
        QLineEdit *themesPath;
        void load(Config *config);
        void save(Config *config);
        Config *configRef;
    public slots:
        void browse(QLineEdit *line);
        void applySlot();
        void okSlot();
    public:
        ConfigDialog(Config *config, QWidget *parent);
    };
    

    and in debug directory not exists moc_configdialog.o/cpp nor configdialog.moc whereas exists moc_codeeditor.cpp,moc_tabwindow.cpp ,codeeditor.moc

    connect(btnOk, SIGNAL(clicked()), this, SLOT(okSlot()));
    

    compiled but not works,

    connect(btnOk,  &QAbstractButton::clicked, this, [this]{ okSlot(); });
    

    works


  • Qt Champions 2017

    You missed adding Q_OBJECT macro in private section of your class



  • After adding I have:

    undefined reference to `vtable for ConfigDialog'

    undefined reference to `ConfigDialog::staticMetaObject'

    Is Ok, after deleting debug directory, Thanks it is solved.


  • Qt Champions 2017

    Delete the build directory and build the project again


Log in to reply