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:
Samuel Gaist 2019-05-16 00:15:40 +02:00
parent 264e66afb2
commit 895db969a5

View File

@ -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);
}