Я получил сигнал в QML и хочу подключиться к слоту, определенному в C++. Однако мой код не работает, и я получаю сообщение об ошибке:
QObject::connect: Нет такого сигнала QDeclarativeContext::sent() в ../qt_cpp/mainwindow.cpp:66
Вот фрагмент кода С++:
message_reading test;
QDeclarativeView tempview;
tempview.setSource(QUrl("qrc:/qml/media_screen.qml"));
QObject *item = tempview.rootContext();
QObject::connect(item, SIGNAL(sent()),
&test, SLOT(readMediaJSONDatabase(QString&)));
А вот фрагмент кода QML:
Image {
id: bluetooth
source: "images_mediahub/footer_icons/bluetooth_normal.png"
signal sent(string msg)
MouseArea {
anchors.fill: parent
onClicked: {
bluetooth.sent(Test.medialibrarydb.toString())
info_load.source="./bluetooth.qml"
}
}
}