PDA

View Full Version : Fully transparent, dragable window



Redar
8th February 2013, 15:28
Hello,

I want to create an invisible, frameless, dragable window with two visible buttons.
Frameless an invisible works fine when I use:
setWindowFlags(Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground);
Added Buttons are visible.

But if I click around the buttons, where the invisible mainWindow should be, the click goes right through to whatever application there behind is.
I reimplemented the mouseMoveEvent and mousePressEvent, to drag the main window. When the window is visible this works great:

void MainWindow::mouseMoveEvent(QMouseEvent *event)
{
move(event->globalX()-m_nMouseClick_X_Coordinate,event->globalY()-m_nMouseClick_Y_Coordinate);
}

void MainWindow::mousePressEvent(QMouseEvent *event)
{
m_nMouseClick_X_Coordinate = event->x();
m_nMouseClick_Y_Coordinate = event->y();
qDebug() << "mouse press event" << endl;
}

If it is invisible nothing happens.

How can I make the invisible area of the mainwindow clickable, so i can drag it?

Regards

Redar

Edit: This program should run on windows

wysota
8th February 2013, 16:52
I think your requirements are contradictory. You want to be able to click and drag the invisible window but at the same time you want the click to go through the underlying app. So which is it?

Redar
8th February 2013, 17:05
I think your requirements are contradictory. You want to be able to click and drag the invisible window but at the same time you want the click to go through the underlying app. So which is it?

Sorry, I thought it was clear.

I want the invisible window click and dragable.
I don't want that the click goes through.

wysota
8th February 2013, 17:36
You can make your widget grab the mouse. Just remember to release it at some point.

Redar
8th February 2013, 18:22
I just tried grabMouse.
Problem is that grabMouse works if the widget is visible, but setAttribute(Qt::WA_TranslucentBackground) sets the widget invisible, so grabMouse has no effect.