2

Inspired by this Answer QML - Import external JavaScript file I am trying to load a .js file from a external URL.

import QtQuick 2.9
import QtQuick.Window 2.2

import 'http://code.qt.io/cgit/qt/qtdeclarative.git/plain/examples/quick/demos/photoviewer/PhotoViewerCore/script/script.js' as Test

Window {
    id: window
    visible: true
    width: 600
    height: 600

    Component.onCompleted: console.log('It is:', Test.calculateScale(100, 100, 200) + '!\nMagical!')
}

But with the import 'http://...' statement my application is not even starting / crashes immediately after start (without any error message).

I have the strong feeling that I am missing something to get the external import working, but I have no idea what exactly.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
IIIIIIIIIIIIIIIIIIIIII
  • 3,958
  • 5
  • 45
  • 70
  • This is probably some incompatibillity of the "new" diskcache functionallity of Qt, where the result of the JIT when loading a QML file is stored, so that it has not to be rebuilt. Try to dissalbe diskcaching. https://stackoverflow.com/questions/41922581/can-qml-caching-in-qt-5-8-be-disabled-for-a-particular-project – derM - not here for BOT dreams Mar 07 '18 at 13:56
  • Also you might try to get that problem fixed (if that is possible) by filing a bug report. – derM - not here for BOT dreams Mar 07 '18 at 13:57
  • Thank you, your first comment helped me with the error message. But my application is still not starting / crashes immediately after start (without an error message now). – IIIIIIIIIIIIIIIIIIIIII Mar 07 '18 at 14:00
  • Can you try, instead of importing a script, to load an image via HTTP? There might be problems for your Qt app to load anything from the net. Maybe problems with the proxy. – derM - not here for BOT dreams Mar 07 '18 at 14:03
  • @derM `Image {source: 'http://.....'}` works :/ – IIIIIIIIIIIIIIIIIIIIII Mar 07 '18 at 14:07
  • I will check the problem, once I am home. I can't test anything right now. – derM - not here for BOT dreams Mar 07 '18 at 14:09
  • @derM thank you for your help! To reproduce my problem: I created a new QtQuick project and only changed main.qml like you can see in my question – IIIIIIIIIIIIIIIIIIIIII Mar 07 '18 at 14:13
  • @IIIIIIIIIIIIIIIIIIIIII I have tried your code and it works, probably the problem is caused by a problem in your internet network blocking the request or there is a long delay causing certain elements are not defined. – eyllanesc Mar 07 '18 at 17:19
  • I can somehow reproduce your problem, but can't explain it. I have two projects, with (in my opinion) identical setup - in one of them it just loads and loads and loads (so the object tree will be empty and you exit, unless you remove those lines form main.cpp) and in the other one it works fine. It's not like the `include` fails. It will just not terminate somehow... – derM - not here for BOT dreams Mar 08 '18 at 08:10

0 Answers0