
Ask HN: Rendering transparent overlay in cross-platform desktop application? - throwawaygui
I&#x27;m new to desktop GUI development (web developer) and at the simplest level, I&#x27;m trying to do the following across Linux, Mac, and Windows:<p>- Overlay a transparent PNG&#x2F;SVG &amp; text label on the screen.<p>- Stay on top of everything else (as much as the OS&#x2F;window manager allows).<p>- Ideally, not interfere with user input, but I can work around this.<p>I&#x27;ve done a ton of digging on this, and these are my main takeaways:<p>- wxWidgets and TkInter do not support transparency.<p>- I&#x27;ve gotten a hack to work with GTK&#x2F;cairo on Linux, but portability of the transparency part doesn&#x27;t seem likely.<p>- Electron and friends are in the progress of supporting this sort of use-case, but that seems INSANELY resource intensive for my needs.<p>- QT and Java seem to be the only two options that even roughly support this, but I&#x27;d imagine my third requirement of not interfering with user input can only be accomplished through the respective native APIs.<p>Given that all I need is an icon and text rendered transparently on the screen, would it be overly ambitious to try to write the &quot;rendering&quot; part low-level and platform specific (X11, WinAPI, Cocoa?), and have something higher level that toggles&#x2F;abstracts the implementation (either at packaging or runtime, doesn&#x27;t matter)? Are there any good examples of simple GUI applications that build native UI&#x27;s for each platform but communicate with them using cross-platform code? Should I just give up and use QT or Java?<p>I&#x27;m definitely not looking for exact code on how to accomplish this, but rather a high level &quot;how would you do it?&quot; from those experienced with cross-platform desktop app development.<p>Thanks HN!
======
billconan
Use Qt, it has the thing you need.

it doesn't have to handle user input,

you can override QT's event loop to do nothing. Qt's event loop is very
hackable.

[https://kernelcoder.wordpress.com/tag/event-handling-in-
qt/](https://kernelcoder.wordpress.com/tag/event-handling-in-qt/)

~~~
billconan
ok, how to do it,

use qt for ui. create a frameless window and adjust the transparency of your
window to 0.5.

as for user input, you can try to override its eventloop, simply ignore and
bypass events. I have never tried this myself.

if this doesn't work, you might need to do some platform dependent code. for
example creating an event filter, capture operating system event before qt
does and throw it away.

I have done this on windows, but I didn't try this on mac.

you can ask on the official qt forum if you have any trouble.

------
dman
What is this overlay meant to do?

~~~
throwawaygui
Essentially I'm after the same sort of effect they had in Screenhero[0], so
showing the location and name of other people's cursors on your screen.

0: [http://media02.hongkiat.com/sharescreen-coworking-
screenhero...](http://media02.hongkiat.com/sharescreen-coworking-
screenhero/screenhero-sharing.jpg)

