[Interest] Problem Using Directory Import for QML Files
Sean Harmer
sean.harmer at kdab.com
Sat Mar 8 01:18:25 CET 2014
On 07/03/2014 03:13, Eric Feigenson wrote:
> Greetings list...
>
> I've also posted this question here:
> http://qt-project.org/forums/viewthread/39195/
>
> 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:
>
> |import "../WeightPlateQtQ"|
>
> (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|import "."|)
>
> My directory structure looks like this:
>
> 1.
> + main.cpp
> 2.
> |
> 3.
> + WPResources.qrc
> 4.
> |
> 5.
> +-qml
> 6.
> |
> 7.
> + WeightPlateQtQ
> 8.
> |
> 9.
> + main.qml
>10.
> |
>11.
> + choosePlates.qml
>
>
> |WPResources.qrc| has this in it:
>
> 1.
> <RCC>
> 2.
> <qresource <http://qt-project.org/doc/QResource.html> prefix="/">
> 3.
> <file>qml/WeightPlateQtQ/main.qml</file>
> 4.
> <file>qml/WeightPlateQtQ/choosePlates.qml</file>
> 5.
> </qresource <http://qt-project.org/doc/QResource.html>>
> 6.
> </RCC>
>
>
> |main.qml| has this import statement (which seems to be OK since it
> gives no error);
>
> 1.
> import "../WeightPlateQtQ"
>
>
> But when I try to use the type |choosePlates| like this, in |main.qml|:
>
> 1.
> choosePlates {
> 2.
> id: platechooser
> 3.
> x: 15
> 4.
> y: 150
> 5.
> text: qsTr("Magic")
> 6.
> width: 200
> 7.
> height: 200
> 8.
> }
>
>
> I get the error:
>
> 1.
> qrc:/qml/WeightPlateQtQ/main.qml:88:5: Cannot assign to
> non-existent property "choosePlates"
>
>
> |choosePlates.qml| just looks like this right now:
>
> 1.
> import QtQuick 2.1
> 2.
> import QtQuick.Controls 1.0
> 3.
> 4.
> Rectangle {
> 5.
> width: 1
> 6.
> height: 1
> 7.
> color: "purple"
> 8.
> }
>
>
> 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?
>
Have you tried not doing import "../WeightPlateQtQ", changing your QML
file to start with an uppercase character e.g. ChoosePlates.qml and
using the element name with a capital e.g. ChoosePlates {...}?
The QML engine looks for components with capital letters as the first
character of the file name.
Cheers,
Sean
--
Dr Sean Harmer | sean.harmer at kdab.com | Managing Director UK
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - Qt Experts - Platform-independent software solutions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140308/f73f7712/attachment.html>
More information about the Interest
mailing list