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. Is it possible to change value of widget when animation loop is incremented?

Is it possible to change value of widget when animation loop is incremented?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 208 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.
  • I Offline
    I Offline
    IHatePython
    wrote on last edited by
    #1

    Hello!
    I wonder if there is possibility to change position of widget after loop. For example, we have widget that is being animated and if animation ends we change its position and animate it again (something like reset, but in other place/position).

    I was thinking about creating individual class derived from QAbstractAnimation just to override LoopCount or function responsible for looping, but i am lost right know and i don't know if there isn't maybe easier and faster way to go. It should look
    like this:

    Endless Loop {

    1. animate
    2. if animation ends, change position of widget
    3. animate it again

    }

    Do you know any hints? I will be grateful :)
    Cheers!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You can use the currentLoopChanged to get that information.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • I Offline
        I Offline
        IHatePython
        wrote on last edited by
        #3

        Thanks for reply, however i still can't do it. I am struggling with connecting animation with any widget.

        animation = new QPropertyAnimation(ui->label_2, "geometry");
        //code handling animation...
        QObject::connect(animation, SIGNAL(currentLoopChanged()), ui->pushButton, SLOT(changeText()));
        

        This is doing nothing. Like signal is not being send.

        ChangeText function:

        void MainWindow::changeText(int) {
            int randomValue = random<int>(this->height() - this->height(), this->height());
            ui->pushButton->setText(QString::number(randomValue));
        }
        

        Do you see something suspicious in this connect?
        Awww this problem is devouring so much time haha! For sure it is, because my Qt5 knowledge is so tiny :)
        Cheers!

        1 Reply Last reply
        0
        • I Offline
          I Offline
          IHatePython
          wrote on last edited by
          #4

          Alright nevermind, finally i understood how connections work and i implemented one properly this time. Thanks for help.

          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