littlepig
9th February 2011, 12:34
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
class MainWindow : public QMainWindow
{
Q_OBJECT
/* code here */
public slots:
void changeWindow(int);
}
another class
class MainMenu : public QWidget
{
Q_OBJECT
private:
QPushButton *optionsB;
/* code here */
public:
void setup(MainWindow*window);
};
where setup have:
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
}
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...
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
class MainWindow : public QMainWindow
{
Q_OBJECT
/* code here */
public slots:
void changeWindow(int);
}
another class
class MainMenu : public QWidget
{
Q_OBJECT
private:
QPushButton *optionsB;
/* code here */
public:
void setup(MainWindow*window);
};
where setup have:
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
}
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...