Temporary white border on resizing Qt Quick application window on Windows Desktop
I'm trying to create a QT Quick Desktop app for Windows with transparent background.
I could manage to reach an application window with transparent background.
The problem is, that the application shall be possible to resize in smooth way.
The resizing itself works as expected, the problem I face is more, that when I change the size of the
application window there appears a temporary white border, which again disappears, when I stop resizing.
For example if I run my application and I use standard window method to change the width of the window by using the mouse cursor on the application window border there appears a white border temorarily until I stop resizing.
It is interesting, that this happens only when enlarging the size, never when decreasing it.
This is my code:
import QtQuick 2.6
import QtQuick.Controls 1.5
import QtQuick.Dialogs 1.2
import QtQuick.Window 2.0
import QtQuick.Controls.Styles 1.4
property int vpSourceWidth: 440
property int vpSourceHeight: 680
// flags: Qt.FramelessWindowHint || Qt.CustomizeWindowHint
visible: true width: vpSourceWidth height: vpSourceHeight color: "transparent"
Is there a way to get rid of that white border, for example to set main application window transition/animation to transparent?
I assume you are on Windows.
This is due to Windows drawing a background before qml does (qml does not redraw fast enough and you see the white background before it can be filled with a transparent value)
You can use Win32 calls from c++ to customise this
WId id = window()->winId(); SetClassLongPtr(HWND(id), GCLP_HBRBACKGROUND, LONG_PTR(GetStockObject(NULL_BRUSH)));
This is far from perfect since if the whole window begins to flicker (which can happen too on resize) then you will not see white but the whole window disappearing instead