Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [qt5] Transparent (windows 7 aero) widget
Qt 6.11 is out! See what's new in the release blog

[qt5] Transparent (windows 7 aero) widget

Scheduled Pinned Locked Moved General and Desktop
17 Posts 8 Posters 17.5k Views 1 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.
  • B Offline
    B Offline
    billouparis
    wrote on last edited by
    #8

    Ok apparently my code is OK
    @#include <QtGui/QGuiApplication>
    #include "qtquick2applicationviewer.h"
    #include <QSurface>
    #include <QSurfaceFormat>
    #include <QDebug>

    int main(int argc, char *argv[])
    {
    QGuiApplication app(argc, argv);

    QtQuick2ApplicationViewer viewer;
    
    viewer.setSurfaceType(QSurface::OpenGLSurface);
    
    QSurfaceFormat format;
    format.setAlphaBufferSize(8);
    format.setRenderableType(QSurfaceFormat::OpenGL);
    qDebug() <&lt; format.hasAlpha();
    viewer.setFormat(format);
    
    QColor color;
    color.setRedF(0.0);
    color.setGreenF(0.0);
    color.setBlueF(0.0);
    color.setAlphaF(0.0);
    viewer.setColor(color);
    
    viewer.setClearBeforeRendering(true);
    
    //viewer.setFlags(Qt::FramelessWindowHint);
    viewer.setMainQmlFile&#40;QStringLiteral("qml/myProject/main.qml"&#41;);
    viewer.showExpanded();
    
    
    return app.exec();
    

    }
    @

    from my investigation on the Qt5 side in
    void QSGDefaultRenderer::render() and then in
    void QSGBindable::clear(QSGRenderer::ClearMode mode) const,
    the glClear call is performed correctly, but sadly and this is my
    conclusion, Windows is doing something under Qt that can not be directly/easily controlled from within Qt.

    What do you think?
    Bill

    1 Reply Last reply
    0
    • I Offline
      I Offline
      Itehnological
      wrote on last edited by
      #9

      The solution is perfect! +1 from me!
      P.S. Thanks a lot!

      1 Reply Last reply
      0
      • B Offline
        B Offline
        billouparis
        wrote on last edited by
        #10

        Found something in the end.
        First activate the aero feature, second use my test application (source code: http://dl.free.fr/nZHhZVRui),
        finally you will get something that will look like this:

        !http://i48.tinypic.com/35bcxmh.png()!

        Enjoy,
        Bill

        1 Reply Last reply
        0
        • I Offline
          I Offline
          Itehnological
          wrote on last edited by
          #11

          There is a problem with your solution in Windows, when setting:

          @format.setRenderableType(QSurfaceFormat::OpenGL);@

          Which results in the output:
          @Cant find EGLConfig, returning null config
          QQuickWindow: makeCurrent() failed...
          ASSERT: "context" in file opengl\qopenglfunctions.cpp, line 194@

          1 Reply Last reply
          0
          • E Offline
            E Offline
            elpuri
            wrote on last edited by
            #12

            You get that error, because you're asking for an OpenGL surface and your Qt is configured to use ANGLE which provides an OpenGL ES2 interface using DirectX. If you change the parameter to QSurfaceFormat::OpenGLES it'll make the error go away, but I doubt it will make the transparency work as a QQuickWindow is always OpenGL anyway.

            1 Reply Last reply
            0
            • I Offline
              I Offline
              Itehnological
              wrote on last edited by
              #13

              @billouparis How did you achieved transparency in windows having in mind what was said by elpuri?

              1 Reply Last reply
              0
              • B Offline
                B Offline
                billouparis
                wrote on last edited by
                #14

                I must have a build with openGL flag for sure! I compiled Qt libraries myself!

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  diorahman
                  wrote on last edited by
                  #15

                  Hi @billouparis how to build the Qt Lib, without ANGLE? Thanks!

                  1 Reply Last reply
                  0
                  • Z Offline
                    Z Offline
                    zhaoweiwei
                    wrote on last edited by
                    #16

                    Who know why QMainWindow are completely invisible whenever TranslucentBackground is set?
                    as fallow:
                    @int main(int argc, char *argv[])
                    {
                    QApplication::setStyle("cleanlooks");
                    QApplication a(argc, argv);
                    login w; // class login : public QMainWindow
                    w.setWindowTitle("ClientLogin");

                    w.setWindowOpacity(1);
                    w.setWindowFlags(Qt::FramelessWindowHint);
                    

                    #ifndef NEWQT //I define this micro for Qt5, because in qt5 WA_TranslucentBackground will cause window invisible
                    w.setAttribute(Qt::WA_TranslucentBackground);
                    #endif

                    w.show();
                    w.move(200,100);
                    return a.exec&#40;&#41;;
                    

                    }@

                    1 Reply Last reply
                    0
                    • Z Offline
                      Z Offline
                      zhaoweiwei
                      wrote on last edited by
                      #17

                      I have find the resolution in http://qt-project.org/forums/viewthread/24344 Now I have get transparent dialog!

                      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