Error - when adding the qml file to the project.
-
Hi,
I just added an listportalitems.qml under the Resources/Qml.qrc/qml. When I try add in main.qml, The error was shown
qrc:/qml/main.qml:48 Cannot assign to non-existent property "listportalitems"
An Redline appears. I hover the redline the message shown as - "Invalid PropertyName listportalitems.qml" (M16)
How to get rid of this error?
Thanks in advance
-
A QML type can be defined either by a document in a .qml file beginning with a capital letter, or by a QObject-based C++ class.
Rename your file and make first letter capital. Then it will be identified as a QML component.
More info here:
http://doc.qt.io/qt-5/qtqml-documents-definetypes.html#defining-an-object-type-with-a-qml-file -
Thanks a lot p3c0,
It worked. I have an query.
it will be identified as a QML component.
Is any other way to call other.qml in main.qml. Ex: In my scenario, In my app, First I will be showing the Login page, once the user get authenticated, User can view the list of items available in the server.
I followed the below strategy, I created an Login.qml with user authentication code and I created ListPortalitem.qml to list the Portal Items.In the main.qml I called the Login {} and ListPortalitem{}. Am I following the right approach?
Code Snippet: main.qml
import QtQuick 2.3 import QtQuick.Controls 1.2 ApplicationWindow { id: appWindow width: 800 height: 600 title: "MapsV1" Login {} ListPortalitems {} }//ApplicationWindow
Issue: How can I show the ListPortalitems.qml after the user is validated successfully, since validation part is taking part on the Login.QML.
Thanks in advance
-
@Mathan-M Yes your approach is correct.
Issue: How can I show the ListPortalitems.qml after the user is validated successfully, since validation part is taking part on the Login.QML.
To delay the initialization you can use following 2 ways:
Check out whichever is more suitable to your needs. I think
Loader
should suffice in your case.