summaryrefslogtreecommitdiffstats
path: root/examples/network/torrent/mainwindow.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-01-23 11:29:55 +0100
committerMarc Mutz <marc.mutz@kdab.com>2015-02-12 19:40:09 +0000
commitf2e3fdc803b9842b6ba4aefe7becdd42eafc4d38 (patch)
tree02d3c5e43602c6c3c729614fe3655ec9a8b5b8c1 /examples/network/torrent/mainwindow.cpp
parent05c38a9111320da311e5993faf12ce8e1f1713e8 (diff)
examples: migrate to QString::asprintf
Not that many, if any, uses of sprintf here were idiomatic Qt, but that's for another commit. Change-Id: Ic34470d9799942f786770ba9541b29c34d67c6f8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'examples/network/torrent/mainwindow.cpp')
-rw-r--r--examples/network/torrent/mainwindow.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/examples/network/torrent/mainwindow.cpp b/examples/network/torrent/mainwindow.cpp
index 0b493fb42b..653882cfb8 100644
--- a/examples/network/torrent/mainwindow.cpp
+++ b/examples/network/torrent/mainwindow.cpp
@@ -92,7 +92,7 @@ public:
// Set the progress and text values of the style option.
int progress = qobject_cast<MainWindow *>(parent())->clientForRow(index.row())->progress();
progressBarOption.progress = progress < 0 ? 0 : progress;
- progressBarOption.text = QString().sprintf("%d%%", progressBarOption.progress);
+ progressBarOption.text = QString::asprintf("%d%%", progressBarOption.progress);
// Draw the progress bar onto the view.
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &progressBarOption, painter);
@@ -509,8 +509,7 @@ void MainWindow::updateDownloadRate(int bytesPerSecond)
// Update the download rate.
TorrentClient *client = qobject_cast<TorrentClient *>(sender());
int row = rowOfClient(client);
- QString num;
- num.sprintf("%.1f KB/s", bytesPerSecond / 1024.0);
+ const QString num = QString::asprintf("%.1f KB/s", bytesPerSecond / 1024.0);
torrentView->topLevelItem(row)->setText(3, num);
if (!saveChanges) {
@@ -524,8 +523,7 @@ void MainWindow::updateUploadRate(int bytesPerSecond)
// Update the upload rate.
TorrentClient *client = qobject_cast<TorrentClient *>(sender());
int row = rowOfClient(client);
- QString num;
- num.sprintf("%.1f KB/s", bytesPerSecond / 1024.0);
+ const QString num = QString::asprintf("%.1f KB/s", bytesPerSecond / 1024.0);
torrentView->topLevelItem(row)->setText(4, num);
if (!saveChanges) {
@@ -593,14 +591,14 @@ static int rateFromValue(int value)
void MainWindow::setUploadLimit(int value)
{
int rate = rateFromValue(value);
- uploadLimitLabel->setText(tr("%1 KB/s").arg(QString().sprintf("%4d", rate)));
+ uploadLimitLabel->setText(tr("%1 KB/s").arg(QString::asprintf("%4d", rate)));
RateController::instance()->setUploadLimit(rate * 1024);
}
void MainWindow::setDownloadLimit(int value)
{
int rate = rateFromValue(value);
- downloadLimitLabel->setText(tr("%1 KB/s").arg(QString().sprintf("%4d", rate)));
+ downloadLimitLabel->setText(tr("%1 KB/s").arg(QString::asprintf("%4d", rate)));
RateController::instance()->setDownloadLimit(rate * 1024);
}