Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QML Connections: Implicitly defined onFoo properties in Connections are deprecated

Tags:

qt

qt5

qml

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

The corresponding QML code is pasted below

Connections {
    target: AppProxy

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

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.

like image 768
Haozhe Xie Avatar asked Jun 10 '20 06:06

Haozhe Xie


1 Answers

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
    }
}

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

like image 169
luffy Avatar answered Sep 23 '22 12:09

luffy