Hello I have problem with connect QML signal with Qt slot when I use QQuickView here is my main.cpp:
ModelValueReceivers *mvr;
mvr = new ModelValueReceivers();
QQuickView view;
view.setSource(QUrl(("qrc:///Main.qml")));
QQuickView loginScreenView;
loginScreenView.setSource(QUrl(("qrc:///LoginScreen.qml")));
QObject *loginScreen = loginScreenView.rootObject();
QObject::connect(loginScreen, SIGNAL(qmlSignal(QString, int)), mvr->valuesReceivers[U1], SLOT(start(QString, int)));
view.show()
In ModelValueReceivers is slot public slots:
void start(QString ipAddress, int tcpPort);
In LoginScreen.qml I have signal:
signal qmlSignal(string addressIP, int portTCP)
and emit is onClicked
onClicked: {
console.log("onClicked");
qmlSignal(ipTextField.text , parseInt(tcpPortTextField.text))
}
In console I can see log "onClicked" but the slot doesn't start.
in Main.qml I have:
Rectangle {
id: screen; width: 320; height: 480;
color: "#ffffff"
StackView{
id: sv
property StackView sv: sv
initialItem: Qt.resolvedUrl("qrc:///LoginScreen.qml");
} }`
QObject::connect(loginScreen, SIGNAL(exitApp()), &ctrl, SLOT(on_closeAppButton_clicked()));
I have slot int ctrl and the same signal in qml file – SzymsonqmlSignal
in the root object inLoginScreen.qml
or that signal is emited from some child object? Do you see some debug warnings? – Orest Hera