I'm currently trying to fade a specific QLabel in and out. My first try was to use the setAlphaChannel, however this just didn't work. My current approach is to use a for-loop and set the stylesheet of the QLabel. Sadly this makes a unverifiable bug, sometimes the fading works properly, sometimes the QLabel doesn't fade out but is fading in and more random stuff. For me the problem is untraceable.
Here is my current code:
def fade_greeting(self, foo, bar):
for i in range(255, -1, -5):
print(i)
string = "font : 45px; font : bold; color : rgba(220, 220, 220, " + str (i) + "); font-family : HelveticaNeue-UltraLight"
time.sleep(0.2)
self.greeting_text.setStyleSheet(string)
time.sleep(2)
self.greeting_text.setText(greeting())
time.sleep(2)
for i in range(0, 256, 5):
print(i)
string = "font : 45px; font : bold; color : rgba(220, 220, 220, " + str (i) + "); font-family : HelveticaNeue-UltraLight"
time.sleep(0.2)
self.greeting_text.setStyleSheet(string)
Is there something I missed? Or is there maybe a different approach to this problem?
Already thanks for your help!