Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved OS X: Clicks on fully transparent parts of windows no longer passes through in Qt 5.6

    General and Desktop
    qt5.6 frameless transparency qwidget
    2
    9
    2908
    Loading More Posts
    • 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.
    • Guy Gizmo
      Guy Gizmo last edited by

      I'm developing an OS X app that utilizes frameless windows which have areas that are fully transparent. This is done by setting the flag Qt::FramelessWindowHint and setting the attribute Qt::WA_TranslucentBackground on my top level QWidget.

      When built using Qt 5.5, clicking on any portion of the window that was transparent would have the click pass through the window to whatever screen element was underneath it. This is an important feature of the application: only portions of the window that are opaque should receive clicks, while clicking transparent portions should behave like the window is not there.

      I recently updated to the beta of Qt 5.6 since it has some important bug fixes I need. However, now clicks on transparent portions of my windows do not pass through.

      Is there anything I can do to get the behavior I want in Qt 5.6? Is this possibly a new bug?

      1 Reply Last reply Reply Quote 1
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        Shouldn't you also set the Qt::WA_TransparentForMouseEvents attribute for that ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        Guy Gizmo 1 Reply Last reply Reply Quote 0
        • Guy Gizmo
          Guy Gizmo @SGaist last edited by

          @SGaist That would make clicks pass through for the entire window. I just want the transparent parts of the window to have clicks pass through.

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            Then I'd ask on the interest mailing list about that behavior change. You'll find there Qt's developers/maintainers (this forum is more user oriented)

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            Guy Gizmo 1 Reply Last reply Reply Quote 0
            • Guy Gizmo
              Guy Gizmo @SGaist last edited by

              @SGaist et al,
              I tried the mailing list but haven't gotten any response so far. Can anyone recommend anything else to try?

              I'm finding myself stuck with Qt related issues in my app. So far, 5.3.x, 5.5.x, and 5.6 all have different, mutually exclusive bugs that are serious enough that I need to fix them. I suppose I could try 5.4.x and hope it works out. But it'd be much better if I could stay up to date with the latest stable Qt.

              1 Reply Last reply Reply Quote 0
              • Guy Gizmo
                Guy Gizmo last edited by

                This is old but I'm bumping again, as I'm still stuck with this problem. I just tried Qt 5.7.0 and (not unexpectedly) it has the same behavior.

                I'd really like to make use of the features of Qt 5.6 and later, especially since 5.6 is a version with long term support. But as long as I can't find a workaround for this issue, I'm stuck with 5.5.1.

                1 Reply Last reply Reply Quote 0
                • SGaist
                  SGaist Lifetime Qt Champion last edited by

                  If you can create a minimal compilable application that shows the behavior problem then you should take a look at the bug report system and see if something known. If not please consider opening a new report providing your sample application.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  Guy Gizmo 1 Reply Last reply Reply Quote 0
                  • Guy Gizmo
                    Guy Gizmo @SGaist last edited by

                    @SGaist Here is the bug report.

                    In case you or anyone else is interested, here is a minimal sample application that demonstrates the

                    // mainwindow.h
                    #include <QMainWindow>
                    
                    class MainWindow : public QMainWindow
                    {
                    	Q_OBJECT
                    public:
                    	MainWindow(QWidget *parent = 0);
                    protected:
                    	void paintEvent(QPaintEvent *);
                    };
                    
                    // main.cpp
                    #include <QApplication>
                    #include <QPainter>
                    #include "mainwindow.h"
                    
                    MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
                    {
                        setAttribute(Qt::WA_TranslucentBackground);
                    	setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
                    }
                    
                    void MainWindow::paintEvent(QPaintEvent *)
                    {
                    	QPainter windowPainter(this);
                    	windowPainter.setBrush(Qt::red);
                    	windowPainter.drawRect(QRect(0,0,50,50));
                    	windowPainter.setBrush(Qt::transparent);
                    	windowPainter.drawRect(rect().adjusted(0,0,-1,-1));
                    }
                    
                    int main(int argc, char *argv[])
                    {
                    	QApplication a(argc, argv);
                    	MainWindow window;	
                    	window.show();
                    	return a.exec();
                    }
                    

                    The app creates a transparent window that includes a frame outlining the window and a red box. When built with Qt 5.5.x, clicking on the frame or red box will activate the window, and clicking on the transparent area will click whatever element in under the window. When built with Qt 5.6 and later, clicking anywhere inside the frame of the window will activate the window and not pass through the click.

                    1 Reply Last reply Reply Quote 0
                    • SGaist
                      SGaist Lifetime Qt Champion last edited by

                      Thanks for sharing !

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post