[Interest] Problem Using Directory Import for QML Files

Eric Feigenson eric at feigenson.net
Fri Mar 7 04:13:07 CET 2014


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 sayimport “.”)

My directory structure looks like this:

+ main.cpp
|
+ WPResources.qrc
|
+-qml
    |
    + WeightPlateQtQ
                   |
                   + main.qml
                   |
                   + choosePlates.qml

WPResources.qrc has this in it:
<RCC>
    <qresource prefix="/">
        <file>qml/WeightPlateQtQ/main.qml</file>
        <file>qml/WeightPlateQtQ/choosePlates.qml</file>
    </qresource>
</RCC>

main.qml has this import statement (which seems to be OK since it gives no error);
import "../WeightPlateQtQ"

But when I try to use the type choosePlates like this, in main.qml:
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"

choosePlates.qml just looks like this right now:

import QtQuick 2.1
import QtQuick.Controls 1.0
 
Rectangle {
    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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140306/d12c1e55/attachment.html>


More information about the Interest mailing list