Bind Timer with a bool variable.
-
Hey. I how can i make that label to show my counter?
void mainWin::onCount() { if(counter==4) { labb->show(); labb->setText("Hello World"); } counter++; qDebug()<<counter; //i want that counter to be shown with that label2 label2->setText(counter); //i want that label to show my counter }
@thomasGl said in Bind Timer with a bool variable.:
//i want that label to show my counter
Then convert it to a string first using https://doc.qt.io/qt-6/qstring.html#number ...
-
Hey. I how can i make that label to show my counter?
void mainWin::onCount() { if(counter==4) { labb->show(); labb->setText("Hello World"); } counter++; qDebug()<<counter; //i want that counter to be shown with that label2 label2->setText(counter); //i want that label to show my counter }
@thomasGl
As you learn you need to read the documentation for yourself, not ask at every stage.QLabel::setText()
accepts aQString
as its argument. You have a number incounter
. So look through/search the QString Class documentation page for a suitable method to convert a number to string....EDIT
It seems @jsulm has already given this away. Shame! :( It's better you learn how to do programming than just ask and be told.... -
@thomasGl
As you learn you need to read the documentation for yourself, not ask at every stage.QLabel::setText()
accepts aQString
as its argument. You have a number incounter
. So look through/search the QString Class documentation page for a suitable method to convert a number to string....EDIT
It seems @jsulm has already given this away. Shame! :( It's better you learn how to do programming than just ask and be told.... -
Hi guys. I dont understand why the button is sometimes not clickable while moving. So i am starting the Timer with one button click and after that the button is moving but sometime its unclickable.
void mainWindow::timerStart() //timer is starting { if(counter==0) { sTimer->start(1000);
void MainWindow::buttonMove() //Pushbutton random position { int x = rand() % 230; int y = rand() % 245; but->setGeometry(x, y, 50, 70); }
QObject::connect(buttton,&Button::clicked,this,&MainWindow::timerStart); //starts the timer QObject::connect(sTimer,&timer::timeout,this,&MainWindow::buttonMove); //every second the button is moving but i cant always click it because its unclickable i dont understand why? its a Pushbutton
-
Hi guys. I dont understand why the button is sometimes not clickable while moving. So i am starting the Timer with one button click and after that the button is moving but sometime its unclickable.
void mainWindow::timerStart() //timer is starting { if(counter==0) { sTimer->start(1000);
void MainWindow::buttonMove() //Pushbutton random position { int x = rand() % 230; int y = rand() % 245; but->setGeometry(x, y, 50, 70); }
QObject::connect(buttton,&Button::clicked,this,&MainWindow::timerStart); //starts the timer QObject::connect(sTimer,&timer::timeout,this,&MainWindow::buttonMove); //every second the button is moving but i cant always click it because its unclickable i dont understand why? its a Pushbutton
-
@thomasGl said in Bind Timer with a bool variable.:
Do you mean my full code?
No, just a MINIMAL compilable application which shows the problem...