Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6539087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:48:54+00:00 2026-05-25T10:48:54+00:00

Sorry about my broken English. I am using a state machine with animations.I want

  • 0

Sorry about my broken English.

I am using a state machine with animations.I want to implement the fade out/in effect.

state1:
opactiy = 0
visible = False

state2:
opactiy = 1
visible = True

state1 –> state2:
Move the widget from bottom to top, set “visible” property to True first, and then set
“opactiy” from 0.0 to 1.0 in 5 seconds.

state2 –> state1:
Move the widget from top to bottom, its “opactiy” is from 1.0 to 0.0 in 5 seconds, and then set the widget’s “visible” property to False.

But the problem is, when state2 to state1, it always set the “visible” property to False first, so what i see is the widget disappear without fade out effect, even if i use QSequentialAnimationGroup and set opactiy_animation first.

How do i get the fade out effect?

The Code:

self.group_p = QtCore.QParallelAnimationGroup()   
self.group_s = QtCore.QSequentialAnimationGroup()
self.group_sr = QtCore.QSequentialAnimationGroup()

goe = QtGui.QGraphicsOpacityEffect()
self.label_arrow.setGraphicsEffect(goe)
animation_o = QtCore.QPropertyAnimation(goe, "opacity")             
animation_g = QtCore.QPropertyAnimation(self.label_arrow, "geometry")
animation_v = QtCore.QPropertyAnimation(self.label_arrow, "visible")

animation_g.setDuration(5000)
animation_g.setEasingCurve(QEasingCurve.OutBounce)
animation_o.setDuration(5000)

self.group_p.addAnimation(animation_g)
self.group_p.addAnimation(animation_o)                                                                     

self.group_s.addAnimation(self.group_p)
self.group_s.addAnimation(animation_v)

self.group_sr.addAnimation(animation_v)
self.group_sr.addAnimation(self.group_p)

self.machine = QtCore.QStateMachine()
state1 = QState(self.machine)
state2 = QState(self.machine)
self.machine.setInitialState(state1)

state1.assignProperty(self.label_arrow, "geometry", QtCore.QRect(self.label_arrow.x(),\
                        self.label_arrow.y()+100, self.label_arrow.width(), self.label_arrow.height()))
state1.assignProperty(self.label_arrow, "visible", False)
state1.assignProperty(goe, "opacity", 0.5)                                      

state2.assignProperty(self.label_arrow, "geometry", self.label_arrow.geometry())
state2.assignProperty(self.label_arrow, "visible", True)
state2.assignProperty(goe, "opacity", 1)                         

transition = state1.addTransition(self.sig_arrow_animate, state2)
transition.addAnimation(self.group_sr)                            

transition2 = state2.addTransition(self.sig_arrow_animate, state1)
transition2.addAnimation(self.group_s) # set visible to False first!
self.machine.start()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:48:55+00:00Added an answer on May 25, 2026 at 10:48 am

    You can’t animate the visible property, because bool isn’t a supported type for animations. You should remove it from the animation, and use only assignProperty for that property.

    According to the documentation, the end value is also assigned by the QState after the end of the animation. That’s why even though the animation doesn’t work the end value is correct ((edit) and that paragraph was not very helpful, since the animation for the bool is not executed and so the state is changed immediately).

    You need to divide state1 in 2 sub-states, the first with the “geometry” and “opacity” properties, and the second, triggered by the signal propertiesAssigned() that is emitted when all the animations for the current state are finished, with the “visible” property.

    state1_1 = QState(state1)
    state1_2 = QState(state1)
    state1.setInitialState(state1_1)
    
    state1_1.assignProperty(self.label_arrow, "geometry", QtCore.QRect(self.label_arrow.x(),\
                            self.label_arrow.y()+100, self.label_arrow.width(), self.label_arrow.height()))
    state1_1.assignProperty(goe, "opacity", 0.5) 
    
    state1_2.assignProperty(self.label_arrow, "visible", False)
    state1_1.addTransition(state1_1.propertiesAssigned, state1_2)
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a developer from korea.(sorry about my broken english previously :( ) I will
Sorry about my English. I'm developing a flash application using Flex SDK, it's an
sorry about input mistakes, english its not my mother lang. I have this code
Sorry about the title, but I don't know how to say what I want.
[Sorry about the clumsy title - I couldn't figure out the best way to
Sorry about the vague question title, I just want to ascertain some things. Static
Sorry about my English. I'm developing a chess interactive site. There is a lesson
Sorry about my english. Please, i have a problem with divs, i have 3
sorry about the funky title, I was having trouble coming up with one. First
Sorry about the stupid question however I can't see/ not good enough to solve

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.