[Interest] QML Grid's children and findChild doesn't work
Igor Mironchik
igor.mironchik at gmail.com
Mon Apr 11 18:21:54 CEST 2016
Hi,
Seems that delegate can't be found with findChild()...
I solved problem as I use model. I fully removed direct interacting with
Cells on Board...
Thank you guys for your suggestions and help.
On 11.04.2016 18:49, Igor Mironchik wrote:
> Hi,
>
> I have chess board defined in QML as:
>
> Grid {
> id: grid
> rows: 8
> columns: 8
> x: offset
> y: top.y + top.height
> objectName: "grid"
>
> Repeater {
> model: chessBoard
>
> delegate: Cell {
> cellColor: model.CurrentPieceColor
> chessX: index % 8
> chessY: index / 8
> onClicked: board.clicked( x, y )
> onHovered: board.hovered( x, y )
> objectName: "c"+ chessX + chessY
> width: cellWidth
> height: cellHeight
> source: model.CellImageSource
> }
> }
> }
>
> So cell's objectName is something like c00, c01...
>
> In C++ I have
>
> QObject * cell = m_grid->findChild< QObject* > ( "c00" );
>
> But it always return 0 with any cell's name. m_grid is the "grid"
> object...
>
> Am I doing something wrong or this is a bug?
>
> Thank you.
More information about the Interest
mailing list