QTimer help needed
-
But parametras += 1 ====== parametras + 1 and when qtimer is initialized parametras keep growing until i close program... or i misunderstood something?
-
Sometime, I prefer not answering than being rude.
-
sorry for me... i am newbie at qt and trying to do this work..
-
Sorry, i was thinking about a singleshot :).
I see that you create a new label in your function "Metodas", this means that you always make a new label when your timer finishes, I dont think that that is what you want.Just create the timer and label in your constructor and move it in your function.
here is a little example wich works:
In ".h":
@
int xas;
int yas;
QLabel *l;
@In constructor:
@
l = new QLabel(this);
l->setText("Move Please?");
l->setGeometry(0,0,200,20);
l->show();
xas = 1;
yas = 1;
QTimer *t = new QTimer(this);
connect(t,SIGNAL(timeout()),this,SLOT(Metodas()));
t->setInterval(1/30);
t->start(50);
@
in metodas:
@
xas +=1;
yas +=1;
l->move(xas,yas);
@ -
Very big thanks to you!!!! You are genius !
-
And the last question... :) Is there a possibility to make y axis random ? I need that duck would be moving x axis as you mentioned, but i need that it would appear in random place on y axis .
I have tried
@ yas = rand()+240; @
but the duck appears in the value of y axis = 240. Is there a way to make it random? -
ty!!!
-
audrensitas: You do not believe in reading, do you? It is really easy to pick up example code on google when you already know the function name!
You know that the idea behind homeworks is that the pupil learns something? That includes how to find background information. Bugging people on the internet with really basic questions is not the best way to accomplish that in my opinion.
-
And perhaps even more important is then the emerging understanding from reading and digesting such examples. This then allows you to apply techniques and particular building blocks in other situations. Learning should also be fun. Do not be afraid to experiment on your own.