Unsolved Problem importing OpenPGPJS library into QML
-
I've been trying to get this library imported and functioning in QML, but I can't figure out what is wrong. Does anyone have an idea how to fix this?
(its a basic Hello World app to start with)
test.pro ├── Sources │ └── main.cpp └── Resources └── qml.qrc └── / ├── main.qml └── openpgp.js
main.qml:
import QtQuick 2.9 import QtQuick.Window 2.2 import "qrc:/openpgp.js" as Openpgp Window { visible: true width: 640 height: 480 title: qsTr("Hello World") Component.onCompleted: { console.log('Openpgp', Openpgp); console.log('done!') } }
The Error message that I'm getting
qt5ct: using qt5ct plugin QQmlApplicationEngine failed to load component qrc:/main.qml:4 Script qrc:/openpgp.js unavailable qrc:/openpgp.js:9 Expected token `}'
Running the OpenPGPJS library through JSHINT does not report any errors in the library. This is being compiled on Ubuntu Linux with the default version (currently 5.9.5).
-
I think i figured out what is going on. Qt 5.9 does not support ECMAScript 6 code, and the OpenPGPJS library uses it a lot. I switched over to Qt 5.13.0 which has better support for ECMAScript 6, but it still doesn't support 'async', and I'm not going to attempt rewriting the whole library just to get it to work.
So, I guess I'm back to square one.
-
What about doing it in C++?
-
My intent is to do mobile app development, which means I should use QML, and I'm not sure I can use C++ libraries, can I?
I'm still really novice at Qt and QML programming, not sure what the limits actually are. If I can use C++ libraries for mobile development, that would be awesome.
-
@mdcato Qt is first and foremost a C++ library for doing cross platform development. QML is just for doing simple things in the GUI. The real power is the C++ side. Yes, you can do a LOT of things in QML. It is not intended to replace the C++ side of things though.
-
@mdcato said in Problem importing OpenPGPJS library into QML:
I'm not sure I can use C++ libraries, can I?
Yes, you can: https://doc.qt.io/qt-5/qtqml-cppintegration-topic.html