QDesktopWindowDocker

What is it?

QDesktopWindowDocker is simple qt widget which allows you to create widgets docked across entire desktop. It's emitting signal 'edgeReached' when mouse is reaching edge of the screen.

How to use it?

Simply add QDesktopWidget to your e.g MainWindow and configure it, by selecting which edge should be trigger of edgeReached singal and handle this signal. Simple sample (header file):
#ifndef __QMAIN_WINDOW_EXAMPLE_H__
#define __QMAIN_WINDOW_EXAMPLE_H__

#include <QMainWindow>
#include <QWidget>
#include "QDesktopWindowDocker.h"
#include <stdexcept>

class QEvent;

/*
 * \class QMainWindowExample 
 * Represents sample usage of QDesktopWindowDocker with QMainWindow. 
 * Add QDesktopWindowDocker as member of QMainWindow and initialize it
 * properly. Next connect to edgeReached signal and prepare slot. 
 *
 * This example presents case when window should be hidden by default, but
 * when edgeReached signal is emited it should be shown.
 */
class QMainWindowExample : public QMainWindow 
{
	Q_OBJECT

	public:
		/*
		 * simple ctor.
		 * @throw bad_alloc, when unable to allocate memory for docker.
		 */
		QMainWindowExample( QWidget *parent = 0 ) throw (std::bad_alloc);

		/*
		 * simple dtor.
		 */
		~QMainWindowExample();

	private:
		QDesktopWindowDocker *m_pWindowDocker;		/**< window docker made member of this class. */

	protected:
		/*
		 * Mouse leave event.
		 */
		void leaveEvent( QEvent *pEvent );

	private slots:

		/*
		 * Slot for unhiding window when edge is reached.
		 */
		void QMainWindowDockerSlot( const int &rDesktopDockType );
};

#endif /* __QMAIN_WINDOW_EXAMPLE_H__ */

		
Here is source file:

#include "QMainWindowExample.h"
#include <QDebug>
#include <QApplication>
#include <QDesktopWidget>
#include <QRect>
#include <QEvent>


/*
 * Ctor.
 */
QMainWindowExample::QMainWindowExample( QWidget *parent) throw (std::bad_alloc) : 	QMainWindow(parent),
																					m_pWindowDocker( 0 )
{
	this->resize(500,500);

	m_pWindowDocker = new QDesktopWindowDocker( this, TOP_RIGHT_CORNER );
	m_pWindowDocker->enable();

	this->hide();

	connect(m_pWindowDocker, SIGNAL( edgeReached( const int& ) ), this, SLOT( QMainWindowDockerSlot( const int & ) ) );
}

/*
 * Dtor.
 */
QMainWindowExample::~QMainWindowExample()
{
	delete m_pWindowDocker;
}

/*
 * Slot for edgeREached signal.
 */
void QMainWindowExample::QMainWindowDockerSlot( const int &rDesktopDockType )
{
	
	qDebug() << "Got edgeReached slot, edge: " << rDesktopDockType;
	QRect screenRect =	QApplication::desktop()->availableGeometry();

	//TOP_RIGHT_CORNER
	this->move( screenRect.topRight().x() - this->width(), screenRect.topRight().y() );
	
	//BOTTOM_RIGHT_CORNER
	//this->move( screenRect.topRight().x() - this->width(), screenRect.bottomRight().y() - this->height() );

	//TOP_LEFT_CORNER
	//this->move( screenRect.topLeft().x(), screenRect.topLeft().y() );
	
	//BOTTOM_LEFT_CORNER
	//this->move( screenRect.topLeft().x(), screenRect.bottomLeft().y() - this->height() );

	//CENTER_TOP
	//this->move( screenRect.width()/2 - this->width()/2, 0 );

	//CENTER_BOTTOM
	//this->move( screenRect.width()/2 - this->width()/2, screenRect.height() - this->height() );

	this->show();
}

/*
 * Leave event.
 */
void QMainWindowExample::leaveEvent( QEvent *pEvent )
{
	this->hide();
}

On which platforms it's working?

I've tested in on Gentoo machine and Windows Xp machine, no idea how it is bahaving on let's say Mac OS.

Lincense

This widget is provided with LGPL license.

Where to get it?

Take a look here at http://qt-apps.org or at sourceforge download page