Qt's minimal platform example generates images with no alpha channel (opacity).



  • The code to generate this issue is simple.

    class TestWidget : public QWidget
    {
    public:
        TestWidget(QWidget* parent = 0) : QWidget(parent)
        {
            this->setWindowOpacity(.5);
        }
    };
    
    int main(int argc, char *argv[])
    {
        setenv("QT_DEBUG_BACKINGSTORE", "1", 0);
    
        QApplication app(argc, argv);
    
        TestWidget widget;
    
        QCheckBox* checkBox = new QCheckBox(&widget);
              checkBox->setObjectName(QStringLiteral("checkBox"));
              checkBox->setGeometry(QRect(0, 0, 89, 20));
    
        widget.setGeometry(QRect(0, 0, 240, 320));
    
        widget.show();
    
        return app.exec();
    }
    

    When you use the -platform minimal, the generated images have no alpha layer. Instead, the background is tan (which I don't set anywhere).

    I have a custom platform that has the same issue, so if I can find out why the minimal platform does this, I can fix mine also.



  • Hi and welcome to devnet,

    as you can read here (the last post) the minimal plugin is a very basic plugin; so probably it disable most of the graphics features (like alpha channel and so on).

    You have to understand which platform you need to use depending the desired feature of your app



  • I understand minimal is really nothing, just a demo. I need to develop a custom platform for an embedded system that sounds the ARGB to non-standard location. However, first things first, I need a working example for a minimal platform plugin (no window manager dependencies) that simply renders to an image in ARGB format. If I can figure that out, I got the rest.



  • Hi,

    based on your hardware you have to understand what is the right platform to use or if you need to develop you own plugin.



  • @mcosta It turns out that I can use the minimal platform to render an alpha window. I found out through the mailing list.

    The code snippet has no relation whatsoever to what setWindowOpacity is doing. If you are only after having transparent (alpha == 0) areas on the window, then there is no difference with 'minimal' compared to any other platform. In fact it's much easier since you won't need to worry about having transparency functional on the windowing system level. Just writing out pixels with an alpha of 0 is good enough, f.ex.:

    tlw.setAutoFillBackground(true);
    tlw.setBrush(QPalette::Window, Qt::transparent);

    See http://doc.qt.io/qt-5.4/qwidget.html#transparency-and-double-buffering

    Cheers,
    Laszlo

    So, I can achieve what I need with the minimal platform, making a few minor tweaks to output the image to the framebuffer in a unique way.

    Qalette pallete = widget.palette();
    pallete.setBrush(QPalette::Window, Qt::transparent);
    widget.setPalette(pallete);
    widget.show();
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.