0
votes

I downloaded a Qt project but when I want to compile it, it gives the following error on "release" mode:

moc_mainwindow.cpp:-1: error: undefined reference to 'MainWindow::on_pushButton_2_clicked()' moc_adminpage.cpp:-1: error: undefined reference to 'AdminPage::on_pushButton_clicked()'

And doesn't compile at all

On "debug" mode however it does compile and the exe runs BUT then it gives the following warning:

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

And the noted "pushButton" does not do anything when it's clicked!

So I know a little about moc files, but I have never had to actually do anything with them. I'm guessing there is something wrong with them though. It looks like Qt cannot connect my on_pushButton_clicked() function (slot) to pushButton clicked signal.

PS 1: The errors noted in the "release" part take place in the moc files.

PS 2: In each of my moc files on the first line there is an #include "../../FinalProject/mainwindow.h which causes the following warning

no such file o directory

This probably must be it, but how can I fix it ?

1
Are you using qmake as your build system? Did you also download the moc_* files? Have you tried deleting them and let qmake regenerate them?Nikos C.
@NikosC. : yes im using qmake . i tried deleting them . it throws another error at me saying cant find the moc files .A73rnA
Please show the command you're using to build the project, including the call to qmake.Nikos C.
have you tried deleting all "Makefile" files in your build directory?ariwez

1 Answers

0
votes

The errors are caused because you have defined the slots on_pushButton_clicked() and on_lineEdit_editingFinished() but you have not used its. Check your mainwindow.h and delete these slots from private slots: section.