Hello, I'm a newbie to qt programming.
These days, I write a simple image viewer with qt4 on WinXP. My code mainly consists of MyWindow derived from QMainWindow, MyImageWidget derived from QWidget.
Creating objects and showing images are all good but there's a problem with SIGNAL-SLOT connection.
Menus and actions are made in MyWindow::createMenu() before that is shown.
QMenu *fileMenu = menuBar()->addMenu("File");
openAction = fileMenu->addAction("Open");
connect(openAction, SIGNAL(triggered()), this, SLOT(fileOpen()));
return true;
Of course, openAction is a member variable of MyWindow and fileOpen() is a member function of the same class.
When I run the compiled binary, everything seem to be good, but the menu does not work and there's a error message in console window like this:
"Object::connect: No such slot QMainWindow::fileOpen()""
In my opinion, Object::connect function tries to find 'fileOpen' function in QMainWindow. But that is defined in the child class!!
I took some alternatives but I could not find any solution.
Thanks in advance.
Intaek.
Bookmarks