No such slot error
I'm sure this must have been aked a thousend times, but all the solutions I found, where missing Q_OBJECT in the *.h files or not having set keyword slot (well and sometimes not having run the moc).
But let's start from the beginning:
I trying to write a small test application just for learning purposes using KDevelop, cmake and, of course, QT. :) But I'm stuck at the moment as the app claims the following:
Object::connect: No such slot qimageview::about() in /home/jankoh/projects/qimageview/qimageview.cpp:15
Object::connect: (sender name: 'actionAbout')
Object::connect: (receiver name: 'MainWindow')
Here is the code:
class qimageview : public QMainWindow, private Ui::MainWindow
qimageview(QWidget *parent = 0);
#endif // qimageview_H
connect(MainWindow::actionClose, SIGNAL( triggered() ), this, SLOT( close() ) ); connect(MainWindow::actionAbout, SIGNAL( triggered() ), this, SLOT( about() ) );
What am I missing? The moc is freshly generated...
Thank's in advance and best regards, Jan
You do not instantiatie QMainWindow.
Try this as the first line for constructor:
qimageview::qimageview(QWidget *parent) : QMainWindow(parent)
But I am not sure that is the source of the problem. Might also be the strange first argument in both connect statements.
Well, maybe it will help. Do report regardless of the outcome :)
Thanks for the reply, but that change does not effect the error.
I also changed the connect statements to read:
connect(actionClose, SIGNAL( triggered() ), this, SLOT( close() ) );
connect(actionAbout, SIGNAL( triggered() ), this, SLOT( about() ) );
but still no success. Funnyly the first connect works as expected. When I click the close button in the menu, the app closes...
Ah wait, you didn't declare about() as a member of your class!
Change it into:
Then rerun MOC, and recompile.
Damned. Thanks for lighting my mind. What a stupid mistake...
But I still get the error message.