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

Qt Quick GridView variable cellWidth depending on Model is not working

$
0
0
My model is called ContactModel.qml with this code:     import QtQuick 2.2         ListModel {         ListElement {             name: "Jim Williams"             portrait: "item.png"         }         ListElement {             name: "John Brown"             portrait: "item.png"         }         ListElement {             name: "Bill Smyth"             portrait: "item.png"         }     } and in my main.qml,     GridView     {         width: 1360         height: 1120         cellWidth: width / ((ContactModel.count < 3) ? ContactModel.count: 3)         cellHeight: 386         model: ContactModel {}         delegate: Column         {             Image             {                 source: portrait;                 anchors.horizontalCenter: parent.horizontalCenter             }             Text             {                 text: name;                 anchors.horizontalCenter: parent.horizontalCenter             }         }     } Am I not allowed to use ternary operators/logic in qml files? I would like to have the width, height, and positioning vary depending on the amount of input. When I try to output ContactModel.count, I get nothing via messagebox, text, etc.

Viewing all articles
Browse latest Browse all 4972

Latest Images

Trending Articles



Latest Images