I've recently started lerning Qt and I'm facing the following problem:
I want to create sth like a chessboard (empty, doesn't have to do anything for now) - I've drawn a simple interface, but in the middle I need to make a chessboard itself (let's say it will be made out of small QTextBrowsers).
The problem is that the size of chessboard must be specified by user. So, drawing 16 fields and giving them unique objectNames is easy, but I have no idea how to:
- generate those fields 'dynamically'
- generate unique names for them, so I will be able to refer to them later in code eg. field_1_1, field_1_2, field_1_3
Thans in advance,
So what I think you want is a two-dimensional array of fields. That way you can reference the correct field without knowing the name.
More specifically Qt provides QLayoutGrid which, although not a two dimensional array, will give you grid access to widgets by using the
itemAtPosition
method