Qt 5 Frameless Window Opacity Animation problem.
With Qt5, a frameless window with opacity animation turns black at the end of animation.
To make it refresh/update, you need to move your mouse over buttons.
This issue only happens with Qt5.
Is this something I can workaround or bug?
int main(int argc, char *argv)
QApplication a(argc, argv);
// Create transparent popup window.
QWidget* popup = new QWidget(NULL, Qt::WindowFlags(Qt::FramelessWindowHint | Qt::ToolTip));
popup->setWindowFlags(Qt::FramelessWindowHint | Qt::ToolTip);
// Add button to popup window.
QHBoxLayout* layout = new QHBoxLayout(popup);
QPushButton* button1 = new QPushButton(popup);
QPushButton* button2 = new QPushButton(popup);
// Create opacity animation.
QPropertyAnimation* fadeInAnimation = new QPropertyAnimation(popup, "windowOpacity");
// Show popup
As a somewhat crude workaround you might use this:
a.connect(fadeInAnimation, SIGNAL(finished()), popup, SLOT(repaint()));
Thank you for the workaround. It works well with black issue.
However, it didn't solve a flicker when the window initially shows up. I forgot to mention that.
UPDATE: I tried to add following code right before show(), this seems to fix initial flicker issue.
Btw, if you create same popup repeatedly, you'll see black rectangle time to time even with workarounds.
I'd say don't start the animation before you show the window ie. change this:
I am still seeing black rectangle between popups.
you must be using windows 8 which doesnt supports the opengl - or the transparent windows thing
jassim92- of course Windows 8 supports OpenGL and layered composition.
OP actually solved his problem (to an extent) so what are you basing that claim on and what OpenGL has to do with it?
even uglier but working: ;)
QObject::connect( fadeInAnimation, SIGNAL(valueChanged(QVariant)), popup, SLOT(repaint()) );