Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

qml hierarchy with qrc

Tags:

c++

qml

I'm programming a c++/qml application. Since I have many qml-files I wanted to make a directory structure. I already implemented the structure in my filesystem like this:

project
    |- qml
        |- main.qml
        |- widgets
            |- Button.qml
            |- Label.qml

What I now want to do is to use qrc-prefixes to create exactly the same hierarchy:

main.qrc
    /
        main.qml
    /widgets
        Button.qml
        Label.qml

This is my example qml-file:

import QtQuick 2.2

import "widgets"

Item {
    id: window
    width: 800
    height: 480

    Button {
        id: button
        anchors.centerIn parent
        text: "click me"
    }
}

The problem I have, is that the compiler does not know the Button!

EDIT:

Error Message: qrc:///qml/main.qml:4 "widgets": no such directory

like image 452
SGbo Avatar asked Oct 01 '14 07:10

SGbo


1 Answers

The QML-interpreter tries to load your directory at the false place ( filesystem instead of qrc-file ). Try

import "qrc:/widgets"

to solve your issue.

like image 166
KimKulling Avatar answered Oct 25 '22 00:10

KimKulling