qt - QML 连接 : Implicitly defined onFoo properties in Connections are deprecated

标签 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>) { ... }

下面贴出对应的QML代码
Connections {
    target: AppProxy

    onLogsReady: function(logs) {
        textLogs.text = logs
    }
}

哪里onLogsReadyAppProxy 中定义的信号类(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

关于qt - QML 连接 : Implicitly defined onFoo properties in Connections are deprecated,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62297192/

相关文章:

c++ - Qt 网页程序集 : configure kit

javascript - 数学序列创建绑定(bind)循环

c++ - 如何在运行时改变QSqlQueryModel子类的数据模型?

c++ - QMetaObject::invokeMethod:使用继承时没有这样的方法

c++ - qt编程中未初始化的switchcase错误

python - qt.qpa.plugin : Could not load the Qt platform plugin "xcb", 不能初始化Qt平台,但是 "Available platform plugins are: xcb, eglfs......"

javascript - QML:不要使用 'eval' (M23)

c++ - Q_ENUM 中索引的值

qt - 不使用 QML 部署 Qt 项目

c++ - 如何将 C++ 代码中定义的单例对象的信号连接到 QML 组件?