1
votes

I have a Qt Creator project with the following directory layout: Project layout

Now, in file main.qml I am trying to include UePeopleItemDelegate.qml:

import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
import QtMultimedia 5.0
import QtQuick.Layouts 1.0
import QtTest 1.1

import "gui/delegates"

ApplicationWindow {
    id: ueWindowMain
    title: qsTr("TestClient ver 1.00")
    width: Screen.desktopAvailableWidth
    height: Screen.desktopAvailableWidth
    visible: true    
    opacity: 1.0

    contentOrientation: Qt.LandscapeOrientation

    color: "black"

    ListView {
        id: uePeopleListView
        snapMode: ListView.SnapToItem
        highlightRangeMode: ListView.ApplyRange
        anchors.right: parent.right
        anchors.rightMargin: 0
        anchors.bottom: parent.top
        anchors.bottomMargin: -128
        anchors.left: parent.left
        anchors.leftMargin: 0
        anchors.top: parent.top
        anchors.topMargin: 0
        orientation: ListView.Horizontal
        flickableDirection: Flickable.HorizontalFlick
        antialiasing: true
        delegate: UePeopleItemDelegate
        model: ListModel {
            ListElement {
                name: "Grey"
                colorCode: "grey"
            }

            ListElement {
                name: "Red"
                colorCode: "red"
            }

            ListElement {
                name: "Blue"
                colorCode: "blue"
            }

            ListElement {
                name: "Green"
                colorCode: "green"
            }
        }
    }
}

The project compiles and builds without problem, however, I get the following runtime error, which is related to QML:

qrc:/main.qml:43: ReferenceError: UePeopleItemDelegate is not defined.

The error refers to line

delegate: UePeopleItemDelegate

of main.qml. Why UePeopleItemDelegate is not recognized? I've imported it with import "gui/delegates" statement. What am I missing?

1

1 Answers

4
votes

Maybe the problem is you are not using braces. Try this:

delegate: UePeopleItemDelegate {}