Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-29401

Can’t set WA_TranslucentBackground to a QWidget

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 5.0.0, 5.1.1
    • None
    • Windows XP

    Description

      I'm porting my programs to Qt5, but failed to show a translucent window. It works well when I’m using Qt 4.8.

      Here is the code:

          #include <QtWidgets/QApplication>
          #include <QLabel>
           
          int main(int argc, char *argv[])
          {
           QScopedPointer<QApplication> app(new QApplication(argc, argv));
           
           QWidget w;
           w.resize(500, 400);
           QPalette palette = w.palette();
           palette.setColor(QPalette::Base, Qt::transparent);
           w.setPalette(palette);
           w.setAttribute(Qt::WA_TranslucentBackground);  //this line will make the program crash
           w.setWindowFlags(Qt::FramelessWindowHint);
           
           QLabel *label = new QLabel("Some label", &w);
                  label->setObjectName("label");
           
           w.show();
           
           return app->exec();
          }
      

      If I set the attribute: w.setAttribute(Qt::WA_TranslucentBackground);
      then the program will crash when executing app->exec();
      at _heap_alloc, with a tremendous size. It seems heap corrupted.

      But the code is OK in Qt 4.8.

      I post this in forum(http://qt-project.org/forums/viewthread/24344) but so far no response. So I doubt is it a bug or is there some thing I neglected ?

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              kleint Friedemann Kleint
              weiyuemin weiyuemin
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes