[solved]Cannot call slot=*(
-
LogWindow.h
class LogWindow : public QMainWindow
{
Q_OBJECT
.... //another code
public slots:
void replyClicked();
signals:
void msgSent();
};LogBrain.h
class LogBrain : public LogWindow
{
....
public slots:
void textProcessing();
};LogWindow.cpp
void LogWindow::replyClicked()
{
...
emit msgSent();
}LogBrain.cpp
void LogBrain::textProcessing()
{
....
}main.cpp
int main(int argc, char *argv[])
{
QApplication logApp(argc, argv);
LogWindow *mainWnd = new LogWindow;
LogBrain *logMind = new LogBrain;QObject::connect(mainWnd->ui.pushButton, SIGNAL(clicked()), mainWnd, SLOT(replyClicked())); QObject::connect(mainWnd, SIGNAL(msgSent()), logMind, SLOT(textProcessing())); mainWnd->show(); return logApp.exec();
}
Can't call textProcessing() slot.
I put a breakpoint where signal msgSent() must be emitted and until this moment everything works fine. But then this signal doesn't call slot textProcessing(). I cannot understand what's the problem. I created new project and wrote similar code and there everything is ok and textProcessing() calls without any problems. -
@AntonZelenin said:
Hi
I am wondering if LogBrian also need a Q_OBJECT in top of class def? -
@AntonZelenin
Well, when I add Q_OBJECT to a class. I often go an delete whole build folder as its sometimes a bit
hard to make it run moc fully or something like that. Sometimes a "Clean" also works. -
Hi,
The thing to do when you add/remove the Q_OBJECT macro is to re-run qmake (in the Build menu of Qt Creator). That will it turn trigger moc to run again and see that your class needs to be mocked