Unsolved Import Causing - Qt Quick Emulation Layer Crashed
-
I have been using Qt Creator for a short while and the QML files presented themselves in the Design window just fine. Suddenly now the QML files give me an error as shown below.
My file starts withimport QtQuick 2.0
import QtQuick.Window 2.10
import QtMultimedia 5.9import "jsscript.js" as MyScript
Window {
id: splashscreen
visible: trueIf I comment the import "jsscript.js" as MyScript in the Designer window the file displays fine.
Is there a reason why this has started to happen. Thanks for any help.
-
QtQuick designer of QtCreator doesn't support JavaScript.
It can only change the design related function.Qt Documentation : Qt Quick UI Forms
Therefore, QML file distinguish between as below two files.
-
A. Using in QtQuick designer file:
${ObjectName}Form.ui.qml -
B. JavaScript / Signal Handlers processing file:
${ObjectName}.qml
It would be preferable if B file use only in Edit mode at QtCreator.
For example:SampleForm.ui.qml (this file can use in QtQuickDesigner)
import QtQuick 2.4 Rectangle { id: rectangle color: "blue" property alias mouseArea: mouseArea MouseArea { id: mouseArea width: parent.width height: parent.height } }
Sample.qml(this file can use Edit mode in Qt Creator)
import QtQuick 2.4 import "Console_log.js" as DebugLog SampleForm { mouseArea.onClicked: { //this file can use slot function DebugLog.log() //this file can use js } }
You may be also deepen my comment's understanding by below blog post.
-
-
Thank you for you help, I appreciate you taking the time to help me.