I have this code for a window with two labels (label and lblclicount) and one button (butprint) It is a small tutorial i found on youtube i just add some text arround the variable that count the numbre of clic the user makes . I just want to learn C++ I know how to do this with VisualBasic. Here is the link of the tutorial : https://www.youtube.com/watch?v=Gi3VuB--vjU and bellow i try to explain the things i don't really understand but it works.
void MainWindow::on_butprint_clicked()
{
static int nbrclic = 0;
QString strnbrclic, texte;
nbrclic++;
ui->label->setText("Hello World");
strnbrclic.sprintf("%i", nbrclic);
texte= "Vous avez cliqué " + strnbrclic + " fois.";
ui->lblcliccount->setText(texte);
}
I was thinking i can do
ui->lblclicount->setText("Vous avez cliqué " + nbrclic + " fois.");
(but it doesn't work.)
instead of having to do
strnbrclic.sprintf("%i", nbrclic);
texte= "Vous avez cliqué " + strnbrclic + " fois.";
I think i understand that strnbrclic.sprintf("%i", nbrclic); convert the integer nbrclic in a string and after i add my text and the variable value of nbrclic in a new one ith the line
texte= "Vous avez cliqué " + strnbrclic + " fois.";
I'm french and i'm sorry if my question is not simple to understand.
Thanks in advance