2
votes

I have a basic QML library with a CPP class, a qrc file and a qml file:

CPP file:

qmlRegisterType( QUrl( "qrc:/MyType.qml" ), "LibA", 1, 0, "MyType" );

QRC file:

<RCC>
  <qresource prefix="/">
    <file>MyType.qml</file>
  </qresource>
</RCC>

QML file:

import QtQuick 2.0

Rectangle {
    color: 'blue'
    width: 50
    height: 50
}

When i use it in main.qml works fine but keep saying invalid property name "color" (M16) and its the same for "width" and "height". I know this can stay this way until works, but can be fixed?

Here my main.qml file:

import QtQuick 2.0
import QtQuick.Window 2.0

import LibA 1.0

Window {
    visible : true
    width: 640
    height: 480
    title: "Hello World"

    MyType {
        height: 100
        width: 100
        color: 'yellow'
    }
}

Im using Qt 5.14.2, Thanks in advance, sorry my bad english.

1
Is your main.qml not in the resource file? Why don't you import QtQuick 2.12 in the component as you do in other files?folibis
The main.qml file its in a diferent qrc because its a application. The MyType.qml its in a library i put the same verson o qtquick and keep saying the same thing.Siewdass Sf
I edit the post, QtQuick to 2.0 in an attempt to get an answer to help me correct the problem thx btwSiewdass Sf

1 Answers

0
votes

I was faced with the same problem with the following code (main.qml):

import QtQuick 2.15
import QtQuick.Window 2.15
Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")
}

No error when building on Desktop Qt 5.15, but M16 errors for the properties width, height, visible and title when building for Android Qt 5.15

Then I used

ApplicationWindow

instead of

Window

This code works for Android:

import QtQuick 2.15
import QtQuick.Controls 2.15
ApplicationWindow {
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")
}