Nominate our 2022 Qt Champions!

How to use C++ Painter component on ListView and make it visible.

  • I have declared Line component for using in QML. but when I use it on ListView it not visible.

    this is code:

    import QtQuick 1.0
    import DrawLine 1.0

    Rectangle { id: page
    width: 400; height: 300
    color: "#4d4d4d"

    ListView { 
        id: lineList
        anchors.fill: parent;
        model: lineModel
        delegate: Component {
            Item {
                DrawLine { // this line is not visible
                    name: "testInList";  
                    x1:x1; y1:y1; x2:x2; y2:y2;
                    color: "red"
                Text { // this text is visible
                    text: txt
        ListModel { id: lineModel
            ListElement {
                x1:0; y1:50; x2:800; y2:800; txt:"hello"
    DrawLine { name: "testOutList"; x1:0; y1:0; x2:1200; y2:800; color: "red" ; } // this line is visible


    How to make it visible ?


  • moderator note
    I have deleted your copy of this post in the Desktop and General forum. Please stick to a single forum when you post questions. Multi-posting is not good practice and it will not get you more attention.

  • Apologize with that. I'll stick to a single forum when I post next questions.

Log in to reply