Thursday, December 24, 2009

Qt-widget to visually select the corner of a screen (for popup-windows)

I recently had to create a popup-window that displays active tasks for a user. Because I am frequently annoyed by popups showing at exactly the wrong monitor or position, I included a feature to change the monitor and that monitor's corner that will be used as the popup-position. I'm using QDesktopWidget to find out the available monitors and calculate the correct position for the popup. In the first version of this popup-window, the user had to select the position and monitor using a standard menu. Because that's not very intuitive, I decided to create a widget that displays the available screens in a miniature-preview. The corners of the screens are highlighted and can be selected with the mouse. When the mouse hovers a corner of the preview, a small popup-like window is displayed at that corner's position of the real monitor.

Here are two screenshots:

Screenshot Popup Position Selector on Windows

Screenshot Popup Position Selector on Ubuntu Linux

You can view and download the source in my github-repository and you can download a sample-application for Windows here.


  1. Thanks andri! It's under the use-it-however-you-like license... but I'll add an official BSD-license disclaimer later. I'm alway a bit lazy about this kind of stuff :-) (when writing code that I want to give away, anyways)