Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

quick 2.0 import delegate

$
0
0
Hey I have the following code. And I didn’t manage to import a delegate from a file. I get the Error views/GridView.qml:19: ReferenceError: Elements is not defined main.qml import "views"   Item {     width: 700     height: 360     Rectangle {         anchors.fill: parent         GridView {             anchors.fill: parent         }     } } views/GridView.qml import QtQuick 2.0 import "../elements/" as Elements Item {     id: grid_view     width: 100     height: 62     Rectangle {         id: grid_view_bg         anchors.fill: parent         ListView {             anchors.fill: parent             model: employee_model             orientation: Qt.Horizontal             delegate: Elements.EmployeeDelegate         }     } } elements/EmployeeDelegate.qml import QtQuick 2.0   Component {     Item {         id:employeeContainer         width: 180;         height: parent.height         Rectangle {             id:employeeBody             anchors.fill: parent             anchors.rightMargin: 5             color: "red"             border.color: "black"             Rectangle {                 id: employeeHeader                 color: "#bbdbf3"                 anchors.horizontalCenter: parent.horizontalCenter                 width: parent.width                 height: 40                   Text {                     anchors.centerIn: parent                     text: '<b>Name:</b> ' + employee.name                 }                 border.color: "black"             }             Item {                 id: clipContainer                 anchors.top: employeeHeader.bottom                 anchors.bottom: parent.bottom                 anchors.horizontalCenter: parent.horizontalCenter                 width: parent.width                 Rectangle {                     id: clip_container_bg                     anchors.fill: parent                     border.color: "black"                 }                 ListView {                     id:clipList                     anchors.fill: parent                     model: clip_model                     delegate: clipDelegate                     onModelChanged: {                         console.debug(clip_model);                     }                 }             }         }     } } If I change the GridView.qml to import "../elements/" I get an Error like views/GridView.qml:19: ReferenceError: EmployeeDelegate is not defined How am I supposed to set Delegates to a List view that are defines in a qml file ?

Viewing all articles
Browse latest Browse all 4972

Trending Articles