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?
@
#include <QApplication>
#include <QPushButton>
#include <QHBoxLayout>
#include <QPropertyAnimation>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);
popup->setAttribute(Qt::WA_TranslucentBackground);// Add button to popup window.
QHBoxLayout* layout = new QHBoxLayout(popup);
QPushButton* button1 = new QPushButton(popup);
button1->setFixedSize(200, 300);
layout->addWidget(button1);
QPushButton* button2 = new QPushButton(popup);
button2->setFixedSize(200, 300);
layout->addWidget(button2);// Create opacity animation.
QPropertyAnimation* fadeInAnimation = new QPropertyAnimation(popup, "windowOpacity");
fadeInAnimation->setDuration(1000);
fadeInAnimation->setStartValue(0.0);
fadeInAnimation->setEndValue(1.0);// Show popup
popup->setWindowOpacity(0.0);
fadeInAnimation->start();
popup->show();return a.exec();
}
@
!https://bugreports.qt-project.org/secure/attachment/30717/screenshot-1.jpg! -
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.
@
popup->repaint();
popup->show();
@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:
@
fadeInAnimation->start();
popup->show();
@
to that:
@
popup->show();
fadeInAnimation->start();
@ -
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()) );
@