我在qt4.8.4中将C++信号连接到qml函数。它工作正常,但在应用程序的输出如下警告使得:将C++信号连接到qml插槽时出现警告
对象::连接:没有这样的插槽QDeclarativeItem_QML_9 :: onValue_changed(双) 对象::连接:(发件人名称: '进myWidget')
我已经定义QML插槽这样的:
import QtQuick 1.0
Item {
id: root
property real value : 0
Connections
{
target: controllerObject
onValue_changed :
{
root.value = value
}
}
}
这是我的C++信号和如何将它连接到QML插槽:
ui->view->rootContext()->setContextProperty("controllerObject",this);
ui->view->setSource(QUrl("qrc:/myQml.qml"));
ui->view->setStyleSheet("background-color: rgba(255, 255, 255, 0);");
ui->view->setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing);
ui->view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
connect(this,SIGNAL(value_changed(double)),(QObject *)ui->view->rootObject(),SLOT(onValue_changed(double)));
为什么会发出警告?
如何省略警告?
感谢您的回答。 – 2014-11-24 10:26:16