升级到 Qt 5.15 时收到以下错误消息:
QML Connections: Implicitly defined onFoo properties in Connections are deprecated.
Use this syntax instead: function onFoo(<arguments>) { ... }
下面贴出对应的QML代码
Connections {
target: AppProxy
onLogsReady: function(logs) {
textLogs.text = logs
}
}
哪里的onLogsReady
是一个定义在AppProxy
class:
class AppProxy : public QObject {
Q_OBJECT
Q_DISABLE_COPY(AppProxy)
public:
AppProxy(QObject* parent = 0);
~AppProxy();
signals:
void logsReady(QString logs);
// ...
};
我想知道如何抑制这个警告。
在 Qml 5.15 中,有一种新的连接语法。在你的情况下,它看起来像这样:
Connections {
target: AppProxy
function onLogsReady(logs) {
textLogs.text = logs
}
}
你可以在这里读更多关于它的内容:https://doc.qt.io/qt-5/qml-qtqml-connections.html https://doc.qt.io/qt-5/qml-qtqml-connections.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)