Fix a mistake when using QLatin1String::arg

QLatin1String::arg (and QStringView::arg) only support string-like
arguments, and QLatin1String("%1").arg(123) does *not* produce
the string "123" -- 123 gets routed through the QChar(int) constructor
instead. Fix by using QString.

Change-Id: I96371a15e1af957ef8133e30e79eb3e22b3e9d32
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Giuseppe D'Angelo 2020-11-05 12:08:10 +01:00
parent 4398836817
commit a6903f3da8
2 changed files with 6 additions and 6 deletions

View File

@ -1110,8 +1110,8 @@ void tst_QAbstractItemView::checkIntersectedRect_data()
{
QStandardItemModel *model = new QStandardItemModel;
for (int i = 0; i < rowCount; ++i) {
const QList<QStandardItem *> sil({new QStandardItem(QLatin1String("Row %1 Item").arg(i)),
new QStandardItem(QLatin1String("2nd column"))});
const QList<QStandardItem *> sil({new QStandardItem(QString("Row %1 Item").arg(i)),
new QStandardItem(QString("2nd column"))});
model->appendRow(sil);
}
return model;

View File

@ -4860,13 +4860,13 @@ void tst_QTreeView::checkIntersectedRect_data()
{
QStandardItemModel *model = new QStandardItemModel;
for (int i = 0; i < rowCount; ++i) {
const QList<QStandardItem *> sil({new QStandardItem(QLatin1String("Row %1 Item").arg(i)),
new QStandardItem(QLatin1String("2nd column"))});
const QList<QStandardItem *> sil({new QStandardItem(QString("Row %1 Item").arg(i)),
new QStandardItem(QString("2nd column"))});
model->appendRow(sil);
}
for (int i = 2; i < 4; ++i) {
const QList<QStandardItem *> sil({new QStandardItem(QLatin1String("Row %1 Item").arg(i)),
new QStandardItem(QLatin1String("2nd column"))});
const QList<QStandardItem *> sil({new QStandardItem(QString("Row %1 Item").arg(i)),
new QStandardItem(QString("2nd column"))});
model->item(i)->appendRow(sil);
}
return model;