[Interest] Signals with QByteArray do not work in QML?

Artem Sidyakin artem.sidyakin at qt.io
Fri Oct 12 11:33:30 CEST 2018


Worked fine for me:

signals:
    void someThing(QByteArray smthing);

emit someThing("christina hendricks");

...

#include "backend.h"

qmlRegisterType<Backend>("io.qt.Backend", 1, 0, "Backend");

...

import io.qt.Backend 1.0

Backend { id: backend }

Connections {
    target: backend
    onSomeThing: {
        console.log(smthing); // outputs "qml: christina hendricks"
    }
}

Also looks like you missed “s” in your “Connection”.

---
Artem Sidyakin

> On 11 Oct 2018, at 16:27, Jason H <jhihn at gmx.com> wrote:
> 
> So originally, QByteArray was not supported in QML. Then this happened in 5.8: http://doc.qt.io/qt-5/qtqml-cppintegration-data.html#qbytearray-to-javascript-arraybuffer
> 
> So naturally I tried to emit newData(QByteArray data), but this was not caught by my connections:
> 
> Connection {
>    target: shim
>    onNewData: {
>       console.log(data)
>    }
> }
> 
> I then tested this with having my slot handleNewData(QByteArray data) emit an additional signal hasNewData(bool), added it to the connections, and I was able to get it to work.
> 
> Is this a bug or am I trying to do eomething known to be wrong?
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest



More information about the Interest mailing list