In an QML-Application I instantiate two classes that inherit QObject and one class needs access to the other class. Also both classes are declared to qml in main.cpp by qmlRegisterType. When I use code like the following I get an qqmlprivate-error. This question is similar to this but it's not the same. How can I fix this? Thank you!
TimeControl.h
class TimeControl : public QObject
{
Q_OBJECT
public:
explicit TimeControl(QObject *parent = nullptr);
};
MyTimeTable.h
class MyTimeTable : public QObject
{
Q_OBJECT
public:
explicit MyTimeTable(TimeControl *timeControl, QObject *parent = nullptr);
private:
TimeControl *m_timeControl = nullptr;
};
MyTimeTable.cpp
MyTimeTable::MyTimeTable(TimeControl *timeControl, QObject *parent)
: QObject(parent)
{
m_timeControl = timeControl;
}
main.cpp
qmlRegisterType<TimeControl> ("tld.we.TimeControl", 1, 0, "TimeControl");
qmlRegisterType<MyTimeControl> ("tld.we.MyTimeTable", 1, 0, "MyTimeTable");
TimeControl *timeControl = new TimeControl();
MyTimeTable timeTable(timeControl);
added QML-Code
import tld.we.MyTimeTable 1.0
Popup{
MyTimeTable{
id: timeTable
}
ToolButton{
text: "Update"
onClicked:
timeTable.updateData();
}