Hello,

Thank you.

I successfully drawn chess board. Nice.

Column {
        spacing: 0
        Row {
            // top letters
            Item { width: offset; height: offset; }
            Repeater {
                model: [ "A", "B", "C", "D", "E", "F", "G", "H" ]
                delegate: Text {
                    width: cellWidth
                    height: offset
                    text: modelData
                    horizontalAlignment: Text.AlignHCenter
                    verticalAlignment: Text.AlignVCenter
                }
            }
            Item { width: offset; height: offset; }
        }
        // Rows with cells
        Repeater {
           model: 8
           delegate: Row {
               id: row
               property int rowIndex: index
               // number
               Text {
                    width: offset
                    height: cellHeight
                    text: 8 - index
                    horizontalAlignment: Text.AlignHCenter
                    verticalAlignment: Text.AlignVCenter
               }
               // first row of chess board
               Repeater {
                    model: 8
                    delegate: Cell {
                        cellColor: ( row.rowIndex % 2 === 0
                            ? ( index % 2  === 0 ? "white" : "lightgray" )
: ( index % 2 === 0 ? "lightgray" : "white" ) );
                        chessX: index; chessY: row.rowIndex;
                        onClicked: board.clicked( x, y );
                        onHovered: board.hovered( x, y );
                        objectName: "c"+ chessX + chessY;
                        width: cellWidth;
                        height: cellHeight;
                    }
               }
               // number
               Text {
                    width: offset
                    height: cellHeight
                    text: 8 - index
                    horizontalAlignment: Text.AlignHCenter
                    verticalAlignment: Text.AlignVCenter
               }
           }
        }
        Row {
            // top letters
            Item { width: offset; height: offset; }
            Repeater {
                model: [ "A", "B", "C", "D", "E", "F", "G", "H" ]
                delegate: Text {
                    width: cellWidth
                    height: offset
                    text: modelData
                    horizontalAlignment: Text.AlignHCenter
                    verticalAlignment: Text.AlignVCenter
                }
            }
            Item { width: offset; height: offset; }
        }
    }

But now I need place pieces on board.

In my old code I used

Figure {
        source: "qrc:/img/pawn-white.png"
        x: c06.x
        y: c06.y
        objectName: "pawn-white-1"
        width: cellWidth
        height: cellHeight
    }

Where c06 is id. Is it possible to bind x to x property of Cell by objectName?

Thank you.

On 11.04.2016 16:02, Gian Maxera wrote:
Column {
    spacing: 0
    Row {
        // top letters
        EmptyItem { // use fixed width here so you can align the text }
        Repeater {
  model: [“A”, “B”, … “H”]
            delegate: DisplayTheLetter { … }
        }
        EmpyItem { }
    }
    // Rows with cells
    Repeater {
       model: 8
       delegate: Row {
           // number
           Text {
                // use fixed width and align left the text
                // vertical alignment with anchors
                anchors.verticalCenter: parent.verticalCenter
                text: index+1
           }
           // first row of chess board
           Repeater {
                model: chessBoardModel[index]
                delegate: ASingleCellOfChessBoard { … }
           }
       }
    }
    Row {
        // bottom letters
        EmptyItem { }
        Repeater {
  model: [“A”, “B”, … “H”]
            delegate: DisplayTheLetter { … }
        }
        EmpyItem { }
    }
}

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to