Hao*_*Xie 15 qt qml qt5 qt5.15
升级到 Qt 5.15 时,我收到以下错误消息:
QML Connections: Implicitly defined onFoo properties in Connections are deprecated.
Use this syntax instead: function onFoo(<arguments>) { ... }
Run Code Online (Sandbox Code Playgroud)
下面贴出对应的QML代码
Connections {
target: AppProxy
onLogsReady: function(logs) {
textLogs.text = logs
}
}
Run Code Online (Sandbox Code Playgroud)
其中onLogsReady是AppProxy类中定义的信号:
class AppProxy : public QObject {
Q_OBJECT
Q_DISABLE_COPY(AppProxy)
public:
AppProxy(QObject* parent = 0);
~AppProxy();
signals:
void logsReady(QString logs);
// ...
};
Run Code Online (Sandbox Code Playgroud)
我想知道如何抑制这个警告。
luf*_*ffy 22
在 Qml 5.15 中有一种新的连接语法。在您的情况下,它看起来像这样:
Connections {
target: AppProxy
function onLogsReady(logs) {
textLogs.text = logs
}
}
Run Code Online (Sandbox Code Playgroud)
您可以在此处阅读更多相关信息:https : //doc.qt.io/qt-5/qml-qtqml-connections.html