The singleton one requires QML to be able to create the instance and own it 
doesn't it?

I'd switch to qmlRegisterUncreatableType()


-Even

-----Original Message-----
From: Interest 
[mailto:interest-bounces+even.kristoffersen=honeywell....@qt-project.org] On 
Behalf Of Jason H
Sent: 1. desember 2016 23:46
To: Jason H <jh...@gmx.com>
Cc: Qt Interest <interest@qt-project.org>
Subject: Re: [Interest] QQmlEngine: Illegal attempt to connect to 
PlatformShim(0xb9b2fb58) that is in a different thread than the QML engine 
QQmlApplicationEngine(0xa17e1494.

Still having issues... But made some "progress"
So I changed to using qmlRegisterSingletonType<PlatformShim>("PlatformSupport", 
1, 0 "PlatformShim", &getPlatformShim) However when I do I get 1 of 2 errors:
1. Element is not creatable:  when trying to declare a signal handler like 
PlatformShim { onPushNotificationReceived; {} } 2. Non-existent attached 
object: when trying to declare a signal handler (in QML) 
PlatformShim.onPushTokenReceived: { }

I also added:
QObject *getPlatformShim(QQmlEngine *engine, QJSEngine *scriptEngine) {
        Q_UNUSED(engine)
        Q_UNUSED(scriptEngine)

        return PlatformShim::instance();
}

and
import PlatformSupport 1.0 to the QML 

> Sent: Thursday, December 01, 2016 at 4:45 PM
> From: "Jason H" <jh...@gmx.com>
> To: "Qt Interest" <interest@qt-project.org>
> Subject: [Interest] QQmlEngine: Illegal attempt to connect to 
> PlatformShim(0xb9b2fb58) that is in a different thread than the QML engine 
> QQmlApplicationEngine(0xa17e1494.
>
> I get that error when:
> main.cpp:
> PlatformShim *shim = PlatformShim::instance(); 
> engine.rootContext()->setContextProperty(QStringLiteral("platformShim"
> ), shim);
> 
> In a QML file:
> Connections {
>       target: platformShim
>       onPushTokenReceived: {
>               pushToken = token
>       }
> }
> 
> I thought Connections were ok across threads?
> _______________________________________________
> Interest mailing list
> Interest@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
> 
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to