[Qt-creator] Import QML Errors

Freddy Martinez freddy311082 at gmail.com
Tue Oct 6 06:04:20 CEST 2015


Hello Guys…

I have 2 qml files:

main.qml and
qml/ULineEdit.qml

as you can see, I have a main.qml file at the same level with the qml folder which has a ULineEdit.qml

this is my ULineEdit.qml

import QtQuick 2.0


Rectangle {
    id: idEdit
    property double widthEdit : width
    property double heightEdit : height
    property string placeHolderText: ""
    property color underlineColor
    property color textColor
    property color placeHolderColor
    property Font fontEdit

    // underline for lineEdit
    Rectangle{
        id: underlineId
        color: underlineColor
        width: widthEdit
        height: heightEdit / 10.0
        anchors.bottom: idEdit.bottom
    }

    TextInput{
        id: textId
        font: idEdit.fontEdit
        property bool showPlaceHolder: true

        text: qsTr(placeHolderText)
        width: idEdit.widthEdit
        height: idEdit.height - underlineId.height - 2
        anchors.bottom: underlineId.top
        verticalAlignment: Text.AlignVCenter
        horizontalAlignment: Text.AlignLeft

        onTextChanged: {
            if (textId.text == "")
            {
                textId.text = idEdit.placeHolderText
                textId.color = idEdit.placeHolderColor
                textId.showPlaceHolder = true
            }

            else
            {
                textId.font = idEdit.fontEdit
                textId.showPlaceHolder = false
            }
        }

        onFocusChanged: {
            if (textId.focus == true)
            {
                if (textId.showPlaceHolder == true)
                {
                    textId.text = "";
                }
            }

            else
            {
                // checking if we have to show the placeholder or not
                if (textId.showPlaceHolder == true)
                {
                    textId.text = idEdit.placeHolderText
                    textId.color = idEdit.placeHolderColor
                }
            }
        }

    }
}


and this is my main.qml file

import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Window 2.0

import "./qml"

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Ultra4")
    color: "#F9F9F9"

    Rectangle{
        width: 100
        height: 20
        color: "black"

        ULineEdit{

            widthEdit: 100
            heightEdit: 20
        }
    }
}



the problem is that when I try to run my app, Qt Creator give the following error:

qrc:/main.qml:19 <qrc:/main.qml:19> Type ULineEdit unavailable
qrc:/qml/ULineEdit.qml:4 <qrc:/qml/ULineEdit.qml:4> Element is not creatable.

What is the problem ? because I can’t see it…

regards

=============================================
"El tamaño de tus logros depende del tamaño de tus metas." 
C++ and Qt Senior Developer
Lic. Computer Science
Buenos Aires, Argentina

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20151006/99d9d377/attachment.html>


More information about the Qt-creator mailing list