Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTimer help needed
QtWS25 Last Chance

QTimer help needed

Scheduled Pinned Locked Moved General and Desktop
20 Posts 6 Posters 8.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    audrensitas
    wrote on last edited by
    #11

    But parametras += 1 ====== parametras + 1 and when qtimer is initialized parametras keep growing until i close program... or i misunderstood something?

    1 Reply Last reply
    0
    • F Offline
      F Offline
      florent.revelut
      wrote on last edited by
      #12

      Sometime, I prefer not answering than being rude.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        audrensitas
        wrote on last edited by
        #13

        sorry for me... i am newbie at qt and trying to do this work..

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vinb
          wrote on last edited by
          #14

          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);
          @

          1 Reply Last reply
          0
          • A Offline
            A Offline
            audrensitas
            wrote on last edited by
            #15

            Very big thanks to you!!!! You are genius !

            1 Reply Last reply
            0
            • A Offline
              A Offline
              audrensitas
              wrote on last edited by
              #16

              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?

              1 Reply Last reply
              0
              • G Offline
                G Offline
                giesbert
                wrote on last edited by
                #17

                Hi audrensitas,

                call
                @
                srand(time(0));
                @

                once (e.g. in main);

                then call

                @
                yas = rand() % 240;
                @

                Nokia Certified Qt Specialist.
                Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  audrensitas
                  wrote on last edited by
                  #18

                  ty!!!

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    tobias.hunger
                    wrote on last edited by
                    #19

                    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.

                    1 Reply Last reply
                    0
                    • Z Offline
                      Z Offline
                      ZapB
                      wrote on last edited by
                      #20

                      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.

                      Nokia Certified Qt Specialist
                      Interested in hearing about Qt related work

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved