3

I have a top level Frameless QMainWindow with Translucency. I have the undesirable effect of click-through (to the underlying window) in the transparent portions of the window.

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow *window = new MainWindow;
    window->setWindowFlags(window->windowFlags() | Qt::FramelessWindowHint);
    window->setAttribute(Qt::WA_TranslucentBackground);
    QLabel *label = new QLabel("Hello World!");
//  window->setStyleSheet("background-color: rgba(0,0,0,1%)");
    window->setCentralWidget(label);
    window->show();

    return a.exec();
}

Is this the expected behavior and, if not, is there a way to work around this.

user1055604
  • 1,624
  • 11
  • 28

1 Answers1

0

I have what is at best a partial solution to this problem:

#include <QtWinExtras>
...
QtWin::extendFrameIntoClientArea(window, -1, -1, -1, -1);

This breaks the click-through behaviour but works only on Windows 7 when Aero Theme (that is to say desktop composition) is enabled and only for Qt 5.2 onwards (as winextras was introduced in 5.2).

This works for me. Hope this is helpful in general. Would still like a more general solution to the problem or perhaps a confirmation that this is the expected behavior.

user1055604
  • 1,624
  • 11
  • 28