Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt's minimal platform example generates images with no alpha channel (opacity).
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Mobile and Embedded
5 Posts 2 Posters 1.6k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    theonlylawislove
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      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

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      1 Reply Last reply
      0
      • T Offline
        T Offline
        theonlylawislove
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mcosta
          wrote on last edited by
          #4

          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.

          Once your problem is solved don't forget to:

          • Mark the thread as SOLVED using the Topic Tool menu
          • Vote up the answer(s) that helped you to solve the issue

          You can embed images using (http://imgur.com/) or (http://postimage.org/)

          1 Reply Last reply
          0
          • T Offline
            T Offline
            theonlylawislove
            wrote on last edited by
            #5

            @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();
            
            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved