Unsolved OS X: Clicks on fully transparent parts of windows no longer passes through in Qt 5.6
-
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?
-
Hi,
Shouldn't you also set the
Qt::WA_TransparentForMouseEvents
attribute for that ? -
@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.
-
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)
-
@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.
-
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.
-
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.
-
@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.
-
Thanks for sharing !