Quote Originally Posted by d_stranz View Post
Your ClientRunnable class declares the member variable "Parent" as type QWidget *. QWidget has no slot named "ClientStarted", so the compiler is telling you that. If you want this to work, you need to qobject_cast<ServerMTh *>( parent ) in the ClientRunnable constructor and store it explicitly as ServerMTh * Parent.

In line 79 of ServerMTh.cpp above, you create a ClientRunnable instance with no parent. This will cause a crash as soon as run() executes since Parent will be uninitialized.
Thanks a lot for your reply @d_stranz, mainly for the second detail; I had skipped...

Regarding the first solution, if I'm not wrong, you mean that I should change line 11 of Client.cpp to "Parent = qobject_cast<ServerMTh *>( parent );", and consequently change the declaration of Parent in Client.h (in line 24) to "QServerMTh * Parent;", is that right? Well, when I do so, I get two new error messages in the Qt Editor:
* one in Client.cpp ("use of undeclared identifier ServerMTh"), and
* another one in Client.h ("unknown type name ServerMTh").

Thus, I need to #include "ServerMTh.h" in Client.h (in line 8). This makes the aforementionned errors dissapear, but two new appear in Client.h:
* "unterminated conditional directive" in line 1, and
* "ServerMTh does not name a type" in line 24 (the updated declaration of Parent: ServerMTh *Parent;

Obviously I've created a circular dependency between classes ServerMTh and ClientRunnable. I've been struggling with it, and I think that I've maybe solved (see changes below), with forwarded class declarations in both classes, and including both headers in the cpp files.

Server.h
Qt Code:
  1. #ifndef SERVERMTH_H
  2. #define SERVERMTH_H
  3.  
  4. #include <QFile>
  5. #include <QFileInfo>
  6. #include <QDialog>
  7. #include <QMessageBox>
  8. #include <QProcess>
  9. #include <QProgressDialog>
  10. #include <QString>
  11. #include <QStringList>
  12. #include <QThreadPool>
  13. #include <QElapsedTimer>
  14. #include "BasicDeclarations.h"
  15. class ClientRunnable;
  16. namespace Ui {
  17. class ServerMTh;
  18. }
To copy to clipboard, switch view to plain text mode 

Server.cpp
Qt Code:
  1. #include <QDir>
  2. #include <QTextStream>
  3. #include "ServerMTh.h"
  4. #include "ui_ServerMTh.h"
  5. #include "ClientRunnable.h"
  6.  
  7. ServerMTh::ServerMTh(QWidget *parent, QString designpath, QString design,
  8. int nbr_injections, QStringList *macro_list,
  9. QStringList *trace_list) :
To copy to clipboard, switch view to plain text mode 

Client.h
Qt Code:
  1. #ifndef CLIENT_RUNNABLE_H
  2. #define CLIENT_RUNNABLE_H
  3.  
  4. #include <QObject>
  5. #include <QProcess>
  6. #include <QRunnable>
  7. #include <QString>
  8. class ServerMTh;
  9. class ClientRunnable : public QRunnable
  10. {
  11. Q_OBJECT
  12.  
  13. public:
  14. enum
  15. {
  16. OKCLIENTSTART, KOCLIENTSTART
  17. };
  18.  
  19. ClientRunnable(QWidget *parent = nullptr);
  20. int ID;
  21. QString MacroFile, Design;
  22.  
  23. private:
  24. ServerMTh *Parent;
To copy to clipboard, switch view to plain text mode 

Client.cpp
Qt Code:
  1. #include <QArgument>
  2. #include <QDebug>
  3. #include <QDir>
  4. #include <QFile>
  5. #include <QMetaObject>
  6. #include <QStringList>
  7. #include "ClientRunnable.h"
  8. #include "ServerMTh.h"
  9.  
  10. ClientRunnable::ClientRunnable(QWidget *parent)
  11. {
  12. Parent = qobject_cast<ServerMTh *>(parent);
  13. Status = OKCLIENTSTART;
  14. }
To copy to clipboard, switch view to plain text mode 


Now, I don't get any compiler errors in these classes. But I'm still getting six errors in the moc_ClientRunnable.cpp. I'm completely lost. Can anyone help me, please? I list the errors an the lines where they appear after the code, just in case this can help someone to guess what is/are the problems.

Thanks again!

Qt Code:
  1. /****************************************************************************
  2. ** Meta object code from reading C++ file 'ClientRunnable.h'
  3. **
  4. ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.13.0)
  5. **
  6. ** WARNING! All changes made in this file will be lost!
  7. *****************************************************************************/
  8.  
  9. #include <memory>
  10. #include "../../VFIT_MTh2/ClientRunnable.h"
  11. #include <QtCore/qbytearray.h>
  12. #include <QtCore/qmetatype.h>
  13. #if !defined(Q_MOC_OUTPUT_REVISION)
  14. #error "The header file 'ClientRunnable.h' doesn't include <QObject>."
  15. #elif Q_MOC_OUTPUT_REVISION != 67
  16. #error "This file was generated using the moc from 5.13.0. It"
  17. #error "cannot be used with the include files from this version of Qt."
  18. #error "(The moc has changed too much.)"
  19. #endif
  20.  
  21. QT_BEGIN_MOC_NAMESPACE
  22. QT_WARNING_PUSH
  23. QT_WARNING_DISABLE_DEPRECATED
  24. struct qt_meta_stringdata_ClientRunnable_t {
  25. QByteArrayData data[1];
  26. char stringdata0[15];
  27. };
  28. #define QT_MOC_LITERAL(idx, ofs, len) \
  29. Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
  30. qptrdiff(offsetof(qt_meta_stringdata_ClientRunnable_t, stringdata0) + ofs \
  31. - idx * sizeof(QByteArrayData)) \
  32. )
  33. static const qt_meta_stringdata_ClientRunnable_t qt_meta_stringdata_ClientRunnable = {
  34. {
  35. QT_MOC_LITERAL(0, 0, 14) // "ClientRunnable"
  36.  
  37. },
  38. "ClientRunnable"
  39. };
  40. #undef QT_MOC_LITERAL
  41.  
  42. static const uint qt_meta_data_ClientRunnable[] = {
  43.  
  44. // content:
  45. 8, // revision
  46. 0, // classname
  47. 0, 0, // classinfo
  48. 0, 0, // methods
  49. 0, 0, // properties
  50. 0, 0, // enums/sets
  51. 0, 0, // constructors
  52. 0, // flags
  53. 0, // signalCount
  54.  
  55. 0 // eod
  56. };
  57.  
  58. void ClientRunnable::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
  59. {
  60. Q_UNUSED(_o);
  61. Q_UNUSED(_id);
  62. Q_UNUSED(_c);
  63. Q_UNUSED(_a);
  64. }
  65.  
  66. QT_INIT_METAOBJECT const QMetaObject ClientRunnable::staticMetaObject = { {
  67. &QRunnable::staticMetaObject,
  68. qt_meta_stringdata_ClientRunnable.data,
  69. qt_meta_data_ClientRunnable,
  70. qt_static_metacall,
  71. nullptr,
  72. nullptr
  73. } };
  74.  
  75.  
  76. const QMetaObject *ClientRunnable::metaObject() const
  77. {
  78. return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
  79. }
  80.  
  81. void *ClientRunnable::qt_metacast(const char *_clname)
  82. {
  83. if (!_clname) return nullptr;
  84. if (!strcmp(_clname, qt_meta_stringdata_ClientRunnable.stringdata0))
  85. return static_cast<void*>(this);
  86. return QRunnable::qt_metacast(_clname);
  87. }
  88.  
  89. int ClientRunnable::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
  90. {
  91. _id = QRunnable::qt_metacall(_c, _id, _a);
  92. return _id;
  93. }
  94. QT_WARNING_POP
  95. QT_END_MOC_NAMESPACE
To copy to clipboard, switch view to plain text mode 

* 'staticMetaObject' is not a member of 'QRunnable' : moc_ClientRunnable.cpp (line 67)

In member function 'virtual const QMetaObject* ClientRunnable::metaObject() const' : moc_ClientRunnable.cpp
* 'QScopedPointer <QObjectData> QObject::d_ptr' is protected within this context : moc_ClientRunnable.cpp (line 78)

In file included from C:\Qt\Qt5.13.0\5.13.0\mingw73_64\include\QtCore/QObject:1:0 : QObject (line 1)
from debug\../../VFIT_MTh2/ClientRunnable.h:4 : ClientRunnable.h (line 4)
from debug\moc_ClientRunnable.cpp:10 : moc_ClientRunnable.cpp (line 10)
declared protected here
QScopedPointer<QObjectData> d_ptr; : qobject.h (line 436)
* invalid use of non-static data member 'QObject::d_ptr' : moc_ClientRunnable.cpp (line 78)

In file included from C:\Qt\Qt5.13.0\5.13.0\mingw73_64\include\QtCore/QObject:1:0 : QObject (line 1)
from debug\../../VFIT_MTh2/ClientRunnable.h:4 : ClientRunnable.h (line 4)
from debug\moc_ClientRunnable.cpp:10 : moc_ClientRunnable.cpp (line 10)
declared here
QScopedPointer<QObjectData> d_ptr; : qobject.h (line 436)
* 'QScopedPointer <QObjectData> QObject::d_ptr' is protected within this context : moc_ClientRunnable.cpp (line 78)

In member function 'virtual void* ClientRunnable::qt_metacast(const char*)': moc_ClientRunnable.cpp
* 'qt_metacast' is not a member of 'QRunnable' : moc_ClientRunnable.cpp (line 86)
return QRunnable::qt_metacast(_clname);

In member function 'virtual int ClientRunnable::qt_metacall(QMetaObject::Call, int, void**)': moc_ClientRunnable.cpp
* 'qt_metacall' is not a member of 'QRunnable' : moc_ClientRunnable.cpp (line 91)
_id = QRunnable::qt_metacall(_c, _id, _a);