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. Animation with QPropertyAnimation and QTimer
Forum Updated to NodeBB v4.3 + New Features

Animation with QPropertyAnimation and QTimer

Scheduled Pinned Locked Moved Unsolved General and Desktop
19 Posts 3 Posters 6.2k Views 2 Watching
  • 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #2

    @21sdino said:

    anim1->setStartValue(1);
    anim1->setEndValue(0.3);

    Hi, and welcome
    Im not sure what you say, so im guessing :)

    It sounds like your problem is that the opacity
    stays at 0.3 after animation ends?

    Cant you just set opacity back to 1.0 ?

    1 Reply Last reply
    1
    • 21sdino2 Offline
      21sdino2 Offline
      21sdino
      wrote on last edited by
      #3

      Thank you,
      It is not the problem.
      Even if imposed top 0.3, and the end to 1
      when I run the program a few icons finish the animation with opacity to 1 instead other end with opacity 0.3
      and I do not understand why

      mrjjM 1 Reply Last reply
      0
      • 21sdino2 21sdino

        Thank you,
        It is not the problem.
        Even if imposed top 0.3, and the end to 1
        when I run the program a few icons finish the animation with opacity to 1 instead other end with opacity 0.3
        and I do not understand why

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by mrjj
        #4

        @21sdino said:

        Ok :)

        You should put
        QDebug() << "Called: EX";
        in e1(), e2() etc
        to see if somehow its not called?

        its hard to see from code how it really works.

        note:
        QList<QLabel*> LabelList= mainwindow->findChilden<QLabel *>();

        Gives you all Labels on the parent. ( mainwindow) in a neat list.
        Dont solve your isse but could be nicer code :)

        1 Reply Last reply
        2
        • 21sdino2 Offline
          21sdino2 Offline
          21sdino
          wrote on last edited by
          #5

          the program creates 7 QLabels
          assigns a gray icon
          create an animation
          assigns the animamazione the first icon
          starts a 3 second timer
          the first icon opacifies an illuminated icon to 3 times
          When the timer ends, sometimes the icon is to be illuminated other times it remains opaque

          mrjjM 1 Reply Last reply
          0
          • 21sdino2 21sdino

            the program creates 7 QLabels
            assigns a gray icon
            create an animation
            assigns the animamazione the first icon
            starts a 3 second timer
            the first icon opacifies an illuminated icon to 3 times
            When the timer ends, sometimes the icon is to be illuminated other times it remains opaque

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #6

            @21sdino
            So what u say is that the actual animation
            on 1 icon do not do the same?

            Sometimes it ends right , sometimes not?

            1 Reply Last reply
            0
            • 21sdino2 Offline
              21sdino2 Offline
              21sdino
              wrote on last edited by
              #7

              from time to time changes on all icons, some of it ends up well on some no

              mrjjM 1 Reply Last reply
              0
              • 21sdino2 21sdino

                from time to time changes on all icons, some of it ends up well on some no

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #8

                @21sdino
                well I cant guess from the shown code.

                They should all run for 1 sec.
                But you seem also to send stop to the animation every 3 sec? via the timer.
                connect(timer,SIGNAL(timeout()),anim1,SLOT(stop()));

                So are you sure the logic is as you want?

                1 Reply Last reply
                1
                • 21sdino2 Offline
                  21sdino2 Offline
                  21sdino
                  wrote on last edited by
                  #9

                  I want that when the timer ends the icon appears to be illuminated
                  but this does not work
                  connect (timer, SIGNAL (timeout ()), UI- <label1, SLOT (setPIxmap (pix));

                  mrjjM 1 Reply Last reply
                  0
                  • 21sdino2 21sdino

                    I want that when the timer ends the icon appears to be illuminated
                    but this does not work
                    connect (timer, SIGNAL (timeout ()), UI- <label1, SLOT (setPIxmap (pix));

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    @21sdino
                    nope
                    that is not valid syntax :)
                    connect (timer, SIGNAL (timeout ()), UI- <label1, SLOT (setPIxmap (pix));
                    You cannot just call a function like that with a random parameter. You must use a slot function that
                    has same parameters as the signal. here signal is timeout () and it has no parameters.

                    So Its not how it works. Did u study ?
                    http://doc.qt.io/qt-5/signalsandslots.html

                    you could hook up
                    http://doc.qt.io/qt-5/qabstractanimation.html#finished

                    and then call
                    setPIxmap (pix) in that slot

                    1 Reply Last reply
                    2
                    • 21sdino2 Offline
                      21sdino2 Offline
                      21sdino
                      wrote on last edited by
                      #11

                      so? connect(anim1,SIGNAL(finished()),ui->label1,SLOT(setPixmap(pix)));

                      mrjjM 1 Reply Last reply
                      0
                      • 21sdino2 21sdino

                        so? connect(anim1,SIGNAL(finished()),ui->label1,SLOT(setPixmap(pix)));

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by mrjj
                        #12

                        @21sdino
                        so that is still wrong u cannot just use a random function as slot. u must make your own :)
                        mainwinow.h
                        slots:
                        void AnimFinished();

                        .cpp
                        void mainwindow::AnimFinished() {
                        setPIxmap (pix); /// here its legal
                        }

                        connect(anim1,SIGNAL(finished()),ui->label1,SLOT(AnimFinished()));

                        1 Reply Last reply
                        0
                        • 21sdino2 Offline
                          21sdino2 Offline
                          21sdino
                          wrote on last edited by
                          #13

                          the problem remains the same I do not understand why

                          mrjjM 1 Reply Last reply
                          0
                          • 21sdino2 21sdino

                            the problem remains the same I do not understand why

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by
                            #14

                            @21sdino
                            but when animation is finished, your slot is called
                            and u can then set the pixmap you want?

                            Im not sure which part is not working.

                            1 Reply Last reply
                            0
                            • 21sdino2 Offline
                              21sdino2 Offline
                              21sdino
                              wrote on last edited by
                              #15

                              only it works in more cases than before but not in all

                              mrjjM 1 Reply Last reply
                              0
                              • 21sdino2 21sdino

                                only it works in more cases than before but not in all

                                mrjjM Offline
                                mrjjM Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on last edited by
                                #16

                                @21sdino
                                Ok, i cant tell. seems ok.
                                You should single step and see what is going on.

                                1 Reply Last reply
                                0
                                • 21sdino2 Offline
                                  21sdino2 Offline
                                  21sdino
                                  wrote on last edited by
                                  #17

                                  i'm tring this from 2 days and i'don't find the solution

                                  mrjjM 1 Reply Last reply
                                  0
                                  • 21sdino2 21sdino

                                    i'm tring this from 2 days and i'don't find the solution

                                    mrjjM Offline
                                    mrjjM Offline
                                    mrjj
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #18

                                    @21sdino
                                    ok, but u need to use more QDebug and find out where it fails.
                                    Sadly we cannot just guess it. Or at Least I cannot.

                                    1 Reply Last reply
                                    0
                                    • E Offline
                                      E Offline
                                      euchkatzl
                                      wrote on last edited by
                                      #19

                                      Could you please explain in detail what you want to do ?
                                      Your code does not seem to be very structured.
                                      As @mrjj says we can only guess what you are doing.

                                      I think you have to remove your QGraphicsOpacityEffect after animation ends (ui->label2->setGraphicsEffect(NULL);) because your end value is 0.3 and this means it has no full opacity.

                                      1 Reply Last reply
                                      1

                                      • Login

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