Hi there
I'm having a problem to connect QObjects... I've searched on web a lot and none of the finds seen to help the problem.
I have a class
{
Q_OBJECT
/* code here */
public slots:
void changeWindow(int);
}
class MainWindow : public QMainWindow
{
Q_OBJECT
/* code here */
public slots:
void changeWindow(int);
}
To copy to clipboard, switch view to plain text mode
another class
{
Q_OBJECT
private:
/* code here */
public:
void setup(MainWindow*window);
};
class MainMenu : public QWidget
{
Q_OBJECT
private:
QPushButton *optionsB;
/* code here */
public:
void setup(MainWindow*window);
};
To copy to clipboard, switch view to plain text mode
where setup have:
void MainMenu::setup(MainWindow* mainWindow)
{
/* code here */
signalMapper->setMapping(optionsB, int(1));
QObject::connect(optionsB,
SIGNAL(clicked
()),signalMapper,
SLOT (map
()));
QObject::connect(signalMapper,
SIGNAL(mapped
(int)), mainWindow,
SLOT(changeWindow
(int)));
// line 50 }
void MainMenu::setup(MainWindow* mainWindow)
{
/* code here */
QSignalMapper* signalMapper = new QSignalMapper(this);
signalMapper->setMapping(optionsB, int(1));
QObject::connect(optionsB, SIGNAL(clicked()),signalMapper, SLOT (map()));
QObject::connect(signalMapper, SIGNAL(mapped(int)), mainWindow, SLOT(changeWindow(int))); // line 50
}
To copy to clipboard, switch view to plain text mode
And the following runtime error:
Object::connect: No such slot MainWindow::changeWindow(int) in /Users/jorgecarleitao/Trabalho_Outros/qt/teste/mainmenu.cpp:50
Object::connect: (receiver name: 'MainWindow')
Can someone explain to me what is wrong here? I'm 2 days searching for this problem and I can't find the solution...
Bookmarks