summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-01-23 12:09:25 +0100
committerMarc Mutz <marc.mutz@kdab.com>2015-02-12 19:39:49 +0000
commit08a8a6a842d0bd925ff31acfe2d47286ef393a83 (patch)
tree5f3e0f3c09a0118675b060257923bde13f0fe102
parentdee800e9e9f37a1d7c81dd1814550bb167b09832 (diff)
QtWidgets: assorted migrations to QString::asprintf
Change-Id: I1a9977f52e9ce098944f876bca19669dac44d2c1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/widgets/styles/qcommonstyle.cpp2
-rw-r--r--src/widgets/widgets/qlcdnumber.cpp8
-rw-r--r--tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp2
-rw-r--r--tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp4
-rw-r--r--tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp2
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp8
-rw-r--r--tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp9
7 files changed, 17 insertions, 18 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index c0c37a20a6..a4ecfc547b 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -5199,7 +5199,7 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget
static QPixmap cachedPixmapFromXPM(const char * const *xpm)
{
QPixmap result;
- const QString tag = QString().sprintf("xpm:0x%p", static_cast<const void*>(xpm));
+ const QString tag = QString::asprintf("xpm:0x%p", static_cast<const void*>(xpm));
if (!QPixmapCache::find(tag, &result)) {
result = QPixmap(xpm);
QPixmapCache::insert(tag, result);
diff --git a/src/widgets/widgets/qlcdnumber.cpp b/src/widgets/widgets/qlcdnumber.cpp
index 9d4a9d0095..d17e3e2470 100644
--- a/src/widgets/widgets/qlcdnumber.cpp
+++ b/src/widgets/widgets/qlcdnumber.cpp
@@ -160,13 +160,13 @@ static QString int2string(int num, int base, int ndigits, bool *oflow)
}
switch(base) {
case QLCDNumber::Hex:
- s.sprintf("%*x", ndigits, num);
+ s = QString::asprintf("%*x", ndigits, num);
break;
case QLCDNumber::Dec:
- s.sprintf("%*i", ndigits, num);
+ s = QString::asprintf("%*i", ndigits, num);
break;
case QLCDNumber::Oct:
- s.sprintf("%*o", ndigits, num);
+ s = QString::asprintf("%*o", ndigits, num);
break;
case QLCDNumber::Bin:
{
@@ -219,7 +219,7 @@ static QString double2string(double num, int base, int ndigits, bool *oflow)
} else { // decimal base
int nd = ndigits;
do {
- s.sprintf("%*.*g", ndigits, nd, num);
+ s = QString::asprintf("%*.*g", ndigits, nd, num);
int i = s.indexOf(QLatin1Char('e'));
if (i > 0 && s[i+1]==QLatin1Char('+')) {
s[i] = QLatin1Char(' ');
diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
index bbc5634415..cea08435c9 100644
--- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
+++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
@@ -2004,7 +2004,7 @@ void tst_QListView::taskQTBUG_9455_wrongScrollbarRanges()
QStringList list;
const int nrItems = 8;
for (int i = 0; i < nrItems; i++)
- list << QString().sprintf("item %d", i);
+ list << QString::asprintf("item %d", i);
QStringListModel model(list);
ListView_9455 w;
diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
index eca774f397..5c881369a0 100644
--- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
+++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
@@ -641,8 +641,8 @@ void tst_QTreeWidget::setItemHidden2()
top->setText(0, "ItemList");
for (int i = 1; i <= 4; i++) {
leaf = new QTreeWidgetItem(top);
- leaf->setText(0, QString().sprintf("%d", i));
- leaf->setText(1, QString().sprintf("Item %d", i));
+ leaf->setText(0, QString::asprintf("%d", i));
+ leaf->setText(1, QString::asprintf("Item %d", i));
}
if (testWidget->topLevelItemCount() > 0) {
diff --git a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp
index 841fc4e712..6c88f8731b 100644
--- a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp
+++ b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp
@@ -155,7 +155,7 @@ static void makeRow(QSizePolicy sp, QSizePolicy::Policy hp, QSizePolicy::Policy
int hst, int vst, QSizePolicy::ControlType ct, bool hfw, bool wfh,
Qt::Orientations orients)
{
- QTest::newRow(qPrintable(QString().sprintf("%s-%s-%d-%d-%s-%s-%s",
+ QTest::newRow(qPrintable(QString::asprintf("%s-%s-%d-%d-%s-%s-%s",
PrettyPrint(hp).s(), PrettyPrint(vp).s(), hst, vst,
PrettyPrint(ct).s(),
hfw ? "true" : "false", wfh ? "true" : "false")))
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 2ede68bffd..8775df84c6 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -2465,14 +2465,14 @@ void tst_QWidget::hideWhenFocusWidgetIsChild()
QSKIP("X11: Your window manager is too broken for this test");
QVERIFY(qApp->focusWidget());
- actualFocusWidget.sprintf("%p %s %s", qApp->focusWidget(), qApp->focusWidget()->objectName().toLatin1().constData(), qApp->focusWidget()->metaObject()->className());
- expectedFocusWidget.sprintf("%p %s %s", edit, edit->objectName().toLatin1().constData(), edit->metaObject()->className());
+ actualFocusWidget = QString::asprintf("%p %s %s", qApp->focusWidget(), qApp->focusWidget()->objectName().toLatin1().constData(), qApp->focusWidget()->metaObject()->className());
+ expectedFocusWidget = QString::asprintf("%p %s %s", edit, edit->objectName().toLatin1().constData(), edit->metaObject()->className());
QCOMPARE(actualFocusWidget, expectedFocusWidget);
parentWidget->hide();
qApp->processEvents();
- actualFocusWidget.sprintf("%p %s %s", qApp->focusWidget(), qApp->focusWidget()->objectName().toLatin1().constData(), qApp->focusWidget()->metaObject()->className());
- expectedFocusWidget.sprintf("%p %s %s", edit2, edit2->objectName().toLatin1().constData(), edit2->metaObject()->className());
+ actualFocusWidget = QString::asprintf("%p %s %s", qApp->focusWidget(), qApp->focusWidget()->objectName().toLatin1().constData(), qApp->focusWidget()->metaObject()->className());
+ expectedFocusWidget = QString::asprintf("%p %s %s", edit2, edit2->objectName().toLatin1().constData(), edit2->metaObject()->className());
QCOMPARE(actualFocusWidget, expectedFocusWidget);
}
diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
index 065fc13ee8..dbfeda8104 100644
--- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
@@ -182,7 +182,6 @@ tst_QCompleter::~tst_QCompleter()
void tst_QCompleter::setSourceModel(ModelType type)
{
- QString text;
QTreeWidgetItem *parent, *child;
treeWidget->clear();
switch(type) {
@@ -192,11 +191,11 @@ void tst_QCompleter::setSourceModel(ModelType type)
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 5; j++) {
parent = new QTreeWidgetItem(treeWidget);
- text.sprintf("%c%i", i == 0 ? 'P' : 'p', j);
+ const QString text = QString::asprintf("%c%i", i == 0 ? 'P' : 'p', j);
parent->setText(completionColumn, text);
for (int k = 0; k < 5; k++) {
child = new QTreeWidgetItem(parent);
- QString t = QString().sprintf("c%i", k) + text;
+ QString t = QString::asprintf("c%i", k) + text;
child->setText(completionColumn, t);
}
}
@@ -211,11 +210,11 @@ void tst_QCompleter::setSourceModel(ModelType type)
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 2; j++) {
parent = new QTreeWidgetItem(treeWidget);
- text.sprintf("%c%i", j == 0 ? 'P' : 'p', i);
+ const QString text = QString::asprintf("%c%i", j == 0 ? 'P' : 'p', i);
parent->setText(completionColumn, text);
for (int k = 0; k < 5; k++) {
child = new QTreeWidgetItem(parent);
- QString t = QString().sprintf("c%i", k) + text;
+ QString t = QString::asprintf("c%i", k) + text;
child->setText(completionColumn, t);
}
}