Display of QML image ignoring pixel alpha
-
Hi. Fairly new to QT, but I've noticed that when I display an image where the source is a png file, the alpha for each pixel is ignored. Just where is displayed.
From c++, I'm using QQuickView to load the source and display.
Is there a setting somewhere to make this work?
Image { source: "image.png" }
-
I've figured this out. The problem wasn't in fact due to image files pixel alpha. That works just fine. It had to do with the QQuickView not being transparent. What I am doing is displaying a QQuickView as a borderless window to be used as a popup dialog and I want to see through to the background, where there are no objects in the qml file. (Think of a pop up dialog with rounded corners).
Here's what I'm doing:
QQuickView view; // don't display an icon in the task bar // no border on the window view.setFlags(Qt::SubWindow | Qt::FramelessWindowHint); // make the view transparent so that the edges of the window, // where there is no image, show through to the background QSurfaceFormat surfaceFormat; surfaceFormat.setAlphaBufferSize(8); view.setFormat(surfaceFormat); view.setClearBeforeRendering(true); view.setColor(QColor(Qt::transparent)); // load qml file and display view.setSource(file.qml); view.show();