Results 1 to 3 of 3

Thread: Have translucent window follow mouse

  1. #1
    Join Date
    Oct 2009
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Have translucent window follow mouse

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,716
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Have translucent window follow mouse

    - 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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Have translucent window follow mouse

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. How to get mouse click events outside the Qt window?
    By montylee in forum Qt Programming
    Replies: 11
    Last Post: 13th July 2015, 22:55
  2. Catching Mouse Events on Top-Level Window
    By andyp in forum Qt Programming
    Replies: 6
    Last Post: 8th September 2009, 11:26
  3. Ignore mouse click on window activation
    By shentian in forum Qt Programming
    Replies: 2
    Last Post: 22nd June 2009, 19:08
  4. Replies: 11
    Last Post: 15th July 2008, 14:11
  5. Replies: 2
    Last Post: 24th July 2006, 19:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.