Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Problem importing OpenPGPJS library into QML
Forum Updated to NodeBB v4.3 + New Features

Problem importing OpenPGPJS library into QML

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 4 Posters 612 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • MDCatoM Offline
    MDCatoM Offline
    MDCato
    wrote on last edited by MDCato
    #1

    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).

    MDCatoM 1 Reply Last reply
    0
    • MDCatoM MDCato

      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).

      MDCatoM Offline
      MDCatoM Offline
      MDCato
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • GrecKoG Offline
        GrecKoG Offline
        GrecKo
        Qt Champions 2018
        wrote on last edited by
        #3

        What about doing it in C++?

        1 Reply Last reply
        0
        • MDCatoM Offline
          MDCatoM Offline
          MDCato
          wrote on last edited by
          #4

          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.

          fcarneyF jsulmJ 2 Replies Last reply
          0
          • MDCatoM MDCato

            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.

            fcarneyF Offline
            fcarneyF Offline
            fcarney
            wrote on last edited by
            #5

            @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.

            C++ is a perfectly valid school of magic.

            1 Reply Last reply
            0
            • MDCatoM MDCato

              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.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @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

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved