doc: improve QStandardItemModel code snippet
The snippet currently uses hard coded values for looping which is not good practice. This patch fixes this using rowCount and columnCount. Change-Id: Ie532649353f757843426a18e9a50b86a2278f7a5 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
This commit is contained in:
parent
264e66afb2
commit
895db969a5
@ -50,8 +50,8 @@
|
||||
|
||||
//! [0]
|
||||
QStandardItemModel model(4, 4);
|
||||
for (int row = 0; row < 4; ++row) {
|
||||
for (int column = 0; column < 4; ++column) {
|
||||
for (int row = 0; row < model.rowCount(); ++row) {
|
||||
for (int column = 0; column < model.columnCount(); ++column) {
|
||||
QStandardItem *item = new QStandardItem(QString("row %0, column %1").arg(row).arg(column));
|
||||
model.setItem(row, column, item);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user