QML Connections:不推荐使用 Connections 中隐式定义的 onFoo 属性 [英] QML Connections: Implicitly defined onFoo properties in Connections are deprecated

查看:26
本文介绍了QML Connections:不推荐使用 Connections 中隐式定义的 onFoo 属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

升级到 Qt 5.15 时收到以下错误消息:

I got the following error message when upgraded to Qt 5.15:

QML Connections: Implicitly defined onFoo properties in Connections are deprecated.
Use this syntax instead: function onFoo(<arguments>) { ... }

下面粘贴对应的QML代码

The corresponding QML code is pasted below

Connections {
    target: AppProxy

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

其中 onLogsReady 是在 AppProxy 类中定义的信号:

where the onLogsReady is a signal defined in the AppProxy class:

class AppProxy : public QObject {
  Q_OBJECT
  Q_DISABLE_COPY(AppProxy)

 public:
  AppProxy(QObject* parent = 0);
  ~AppProxy();

 signals:
  void logsReady(QString logs);

// ...
};

我想知道如何抑制这个警告.

I wonder how to suppress this warning.

推荐答案

在 Qml 5.15 中有一个新的连接语法.在您的情况下,它看起来像这样:

in Qml 5.15 there is a new syntax for connections. In your case it would look like this:

Connections {
    target: AppProxy

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

您可以在此处阅读更多信息:https://doc.qt.io/qt-5/qml-qtqml-connections.html

You can read more about it here: https://doc.qt.io/qt-5/qml-qtqml-connections.html

这篇关于QML Connections:不推荐使用 Connections 中隐式定义的 onFoo 属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆