August 14, 2011

Radical Radical
Lab Rat
5 posts

Can I create a translucent window

 

Hi,

I’m using QPixmap.grabWindow to get the contents of an existing X11 App’s window (Orig).

I also want to draw my own translucent window over Orig, so that:

1) grabWindow still works for Orig, as if it isn’t obscured by the visible details in my window
2) mouse and keyboard events pass through my window

I understand the concept of an overlay, but the docs only mention QGLwidget being drawn underneath regular widgets. Is it possible to meet my requirements in Qt?

3 replies

August 14, 2011

rokemoon rokemoon
Lab Rat
197 posts

Try this [developer.qt.nokia.com] for transparent window

August 14, 2011

Radical Radical
Lab Rat
5 posts

Failed to replicate this with qtruby. I’ll try with c++ later.

For now I tried drawing the grabWindow pixmap in MyWindow’s paintEvent. I then set MyWindow to always-on-top in gnome and tried alternately clicking each window’s title-bar while MyWindow was partly covering the original.

Unfortunately this caused recursive garbage. This means the window has to be on top for grabWindow to work. I’ve heard modern X11 implementations maintain a pixmap of each window in memory but I guess xlib and in turn qt ignore this feature.

When I started the thread I was under the impression there was a way of drawing to an overlay, which I thought could exist above the default screen. I’m going to assume this isn’t true.

That leaves raising the original window before I paint mine. So I’m looking for a Qt function which accepts an arbritrary window id and sends a raise event.

August 15, 2011

manishsharma manishsharma
Lab Rat
11 posts

2) mouse and keyboard events pass through my window

1. Qt::WA_TransparentForMouseEvents or 2. QWidget::setMask() -> you need to calculate region of MyWindow which can be painted and pass that to setMask function.
 
  ‹‹ [SOLVED] Problem compiling with Qt Creator      QGLWidget with custom OpenGL context ››

You must log in to post a reply. Not a member yet? Register here!