【发布时间】:2013-08-27 22:06:24
【问题描述】:
我在 QML 中收到一个信号,我想连接到 C++ 中定义的插槽。但是我的代码失败了,我收到了错误:
QObject::connect: ../qt_cpp/mainwindow.cpp:66 中没有这样的信号 QDeclarativeContext::sent()
这是一个c++代码sn-p:
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代码sn-p:
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"
}
}
}
【问题讨论】:
标签: qt qml signals-slots qtquick2