Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [SOLVED] Problem Using Directory Import for QML Files
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Problem Using Directory Import for QML Files

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    EricRFMA
    wrote on last edited by
    #1

    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" @

    <code>choosePlates.qml</code> 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

    1 Reply Last reply
    0
    • T Offline
      T Offline
      thatbloke
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • E Offline
        E Offline
        EricRFMA
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved