Displaying text & integer in a single label?
-
This is a total simple question I think, but:
How do I display a string and a integer in a single label? I tried it to make it like this:
@ int version = 1;
ui->label_3->setText("Version", version);@
or this:
@ int version = 1;
ui->label_3->setText("Version" & version);@
..or this:
@ int version = 1;
ui->label_3->setText("Version" + version);@
Nothing seems to work.. -
@
int version = 1;
ui->label_3->setText("Version" + QString::number(version));
// or:
ui->label_3->setText(QString("Version%1").arg(version));
@ -
or
@
ui->label_3->setText("Version" + QLocale().toString(version));
@
if you care about local number formatting (like space after several zeros or local decimal separator), although in this case it's irrelevant. -
Hey, cool, I didn't know about this one :-)