[SOLVED] Problem Using Directory Import for QML Files
-
I searched the forums and doc, and can't figure this one out...
I'm using Qt Creator 3.1.81 based on Qt 5.2.2 (Mac) with QtQuick 2.1
I'm trying to use a user-defined object type:
<code>import "../WeightPlateQtQ"</code>
(aside: the qml file I'm attempting to import is in the same directory and my main.qml, and yet I have to supply the above import statement. I couldn't just say <code>import "."</code>)
My directory structure looks like this:
@- main.cpp
| - WPResources.qrc
|
+-qml
|- WeightPlateQtQ
|
+ main.qml
|
+ choosePlates.qml
@
<code>WPResources.qrc</code> has this in it:
@<RCC>
<qresource prefix="/">
<file>qml/WeightPlateQtQ/main.qml</file>
<file>qml/WeightPlateQtQ/choosePlates.qml</file>
</qresource>
</RCC>@
<code>main.qml</code> has this import statement (which seems to be OK since it gives no error);
@import "../WeightPlateQtQ"@
But when I try to use the type <code>choosePlates</code> like this, in <code>main.qml</code>:
@choosePlates {
id: platechooser
x: 15
y: 150
text: qsTr("Magic")
width: 200
height: 200
}@
I get the error: @qrc:/qml/WeightPlateQtQ/main.qml:88:5: Cannot assign to non-existent property "choosePlates" @
- WeightPlateQtQ
<code>choosePlates.qml</code> just looks like this right now:
@import QtQuick 2.1
import QtQuick.Controls 1.0Rectangle {
width: 1
height: 1
color: "purple"
}@This looks like it should be really really simple, so I figure I'm just doing something really really naive (or maybe stupid, you never know.)
Can anyone provide enlightenment?
Thanks!
-Eric
- main.cpp
-
I'm pretty sure that the convention is to use a capital letter for element names, so it's nto as simple as renaming choosePlates.qml to ChoosePlates.qml is it?
In addition, if the files are in the same directory, I'm not sure you even need the import statement.
-
That did it!
So... id properties have to start with lowercase (that I read somewhere), but component names have to start with upper case? That I didn't see anywhere.
Thanks bloke!
-Eric