Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. javascript imports errors
Forum Updated to NodeBB v4.3 + New Features

javascript imports errors

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 376 Views 2 Watching
  • 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.
  • M Offline
    M Offline
    mIcHyAmRaNe
    wrote on last edited by mIcHyAmRaNe
    #1

    Hello,
    i'm creating a small app using 'pyside2 + qml' to test and learn
    it has 2 files

    # main.py
    from PySide2.QtWidgets import QApplication
    from PySide2.QtQml import QQmlApplicationEngine
    
    if __name__ == "__main__":
        app = QApplication([])
        engine = QQmlApplicationEngine()
        engine.load('./view.qml')
        app.exec_()
    
    # view.qml
    import QtQuick 2.15
    import QtQuick.Controls 2.15
    import QtQuick.Window 2.2
    import "axios.min.js" as Axios
    

    i'm trying to import some javascript libraries to test them inside my app but i got some errors:

    • when i import axios v0.21.1 : it works fine
    • but when i import axios new versions ( >0.21.1) it doesn't work and i get an error
      TypeError: Value is null and could not be converted to an object

    i tested different libraries like vanillajs and cheerio but getting errors too:

    • vanilla: ReferenceError: exports is not defined
    • cheerio: ReferenceError: exports is not defined

    Any solution?
    or in other words, how to use nodejs libraries with qml ?

    Note: the JS files are taken from jsdelivr cdn

    Thank you

    JKSHJ 1 Reply Last reply
    0
    • M mIcHyAmRaNe

      Hello,
      i'm creating a small app using 'pyside2 + qml' to test and learn
      it has 2 files

      # main.py
      from PySide2.QtWidgets import QApplication
      from PySide2.QtQml import QQmlApplicationEngine
      
      if __name__ == "__main__":
          app = QApplication([])
          engine = QQmlApplicationEngine()
          engine.load('./view.qml')
          app.exec_()
      
      # view.qml
      import QtQuick 2.15
      import QtQuick.Controls 2.15
      import QtQuick.Window 2.2
      import "axios.min.js" as Axios
      

      i'm trying to import some javascript libraries to test them inside my app but i got some errors:

      • when i import axios v0.21.1 : it works fine
      • but when i import axios new versions ( >0.21.1) it doesn't work and i get an error
        TypeError: Value is null and could not be converted to an object

      i tested different libraries like vanillajs and cheerio but getting errors too:

      • vanilla: ReferenceError: exports is not defined
      • cheerio: ReferenceError: exports is not defined

      Any solution?
      or in other words, how to use nodejs libraries with qml ?

      Note: the JS files are taken from jsdelivr cdn

      Thank you

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      @mIcHyAmRaNe said in javascript imports errors:

      • when i import axios v0.21.1 : it works fine
      • but when i import axios new versions ( >0.21.1) it doesn't work and i get an error
        TypeError: Value is null and could not be converted to an object

      It sounds like there were some backward-incompatible changes for versions >0.21.1

      Where is the null value?

      i tested different libraries like vanillajs and cheerio but getting errors too:

      • vanilla: ReferenceError: exports is not defined
      • cheerio: ReferenceError: exports is not defined

      Any solution?
      or in other words, how to use nodejs libraries with qml ?

      If I'm not mistaken, exports are NodeJS extensions, not part of ECMAScript (i.e. standard JavaScript). Qt's JavaScript engine supports ECMAScript 7 as of Qt 5.12.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      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