I have the following main.qml file:
import QtQuick 2.5
import QtQuick.Controls 1.4
Item
{
anchors.centerIn: parent
Label
{
id: textLabel
anchors.fill: parent
x: 200
y: 400
}
CustomObject
{
id: customObjectId
}
}
CustomObject
is a QML
file defined in an external binary resource, generated by the rcc
command:
rcc -binary -o redTheme.qrc redTheme.rcc
CustomObject.qml
import QtQuick 2.5
import QtQuick.Controls 1.4
Item
{
Rectangle
{
width: 200
height: 120
color: "blue"
Label
{
text: "customObject"
}
}
}
In the C++
side, I register my resource like this:
QResource::registerResource(QCoreApplication::applicationDirPath() + "/data/themes/redTheme.rcc");
The function returns true
, which means the file is opened.
Yet, CustomObject
does not exist in my main.qml file. Why?
CustomObject is not a type
EDIT: I've wrapped CustomObject
into a QML Module
and then compiled it into a .rcc
file (it means the qmldir
file is inside the .qrc
). No difference whatsoever, CustomObject
still isn't recognized as a type, even if I add an import
statement (import redTheme 1.0
). Content of my qmldir file:
module redTheme
CustomObject 1.0 CustomObject.qml