Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QML error changing every time program is run
Nubcake last edited by
Let me just start out by saying that a I am new to Qt and have been using it for only a few weeks.
I need some expert advice!
I've been in the process of porting a project, which consists of 50+ C++ and QML files, which was written in Qt 4.8 for Windows 10 to a later version; Qt 5.6.0. Currently I am building my project in Release mode and to build my project I am using:
MSVC 2013 Update 5
I made sure the existing code threw no errors before porting however, after my attempt at porting the old code to Qt 5.6, I am encountering a QML engine error of the form "... is not a type." whenever I run my program. The GUI just opens with a white screen so and I read somewhere that this happens when the QML engine encounters an error. I have searched for my problem online but no one else seems to have the same problem as me. There also does not seem to be any explanation in the Qt documentation about this error either?
It appears on the console whenever I run my program but the thing that drives me crazy is that the error refers to a different type every time I run the program and I don't understand why it is happening. For example if I run the program three times, the object that the QML engine complains about changes everytime:
File.qml 33:5 ConnectionSelector is not a type.
File.qml 53:15 ConnectionWait is not a type.
File.qml 12:6 Screen is not a type.
During the port, I made minimal changes to the QML files; updated their imports of QtQuick to 2.6 and removed some redundant code. All the mentioned QML files are in the .pro file and the folder and are added to the resources file. The structure of the folder hasn't really changed either. I mainly made changes to the C++ source files by changing headers/removing deprecated functions/updating correct objects etc.
In my main.cpp, the error occurs when the function setSource() is called on the QQuickView object.
I don't have access to the source code now as I am at home and I know it is difficult to diagnose without it but does anyone have any advice on how to fix this/knows why this is happening? Has anyone else encountered this problem before?
Help much appreciated.
Hi and welcome to devnet,
The first thing would be to search for these missing types in your code base. If they can be found there, then check Qt's sources to see if you can find them there, first with 4.8 and then 5.6.
Just a side note, Qt 5.9 is the curent LTS which might be more interesting in the long run.
Screen is the only one of those that is a QML component. It needs
import QtQuick.Window 2.2.
The others are probably custom components that are part of the source you are converting. My guess is you don't have your custom components set up properly so they are not being found.