PDA

View Full Version : Have translucent window follow mouse



mike_am_i
27th October 2009, 06:33
Hello,

I just downloaded Qt Creator (using Ubuntu) and so far it seems great. I'd like to make a simple reading assistance application. When turned on, a thin translucent line follows the mouse around the screen. This visual focus increases reading speed.

Basically, I'm wondering how I can get Qt 4.5 to do these things:

- Create a "line" window (no title or system icon) about 300px wide and 6px high that follows mouse around (about 5 px below).
- Have the "line" window be translucent (50%)
- The "line" window doesn't show in "task bar"
- The application has a "tray icon".
- Double-click to bring up a dialog with properties.
- Right click to bring up menu with options.

It's really simple, and I made it in about 2002 with VB. I just switched to Linux and would like to recreate it with Qt or GTK.

Sorry for the windows/vb'isms, but I'd love to learn Qt. Advice on any of the above?

Mike

high_flyer
27th October 2009, 10:16
- Create a "line" window (no title or system icon) about 300px wide and 6px high that follows mouse around (about 5 px below).
Wont using a custom mouse pointer do?

For the points you made all the information is either in the documentation or in this forum.

Once you have read, and started working, ask SPECIFIC questions about problems you have.

wysota
27th October 2009, 10:18
Should be pretty simple. First you need the line itself - you can start with QFrame in horizontal line mode. Then you need to pass appropriate window flags (or attributes) to make it translucent and without window decorations. Finally you need it to follow the mouse - and this is the hard part as there are two choices - either you have to grab the mouse which will make your widget receive all mouse events (meaning you won't be able to click on the desktop or anywhere else until you release the mouse) or use polling of QCursor::pos() every now and then and update position of your item accordingly which will make your line follow the movement of the cursor with a bit of delay.