PDA

View Full Version : How do I natively move a QWidget top-level window?



codeslicer
17th February 2008, 19:01
Is there any way I can "natively" move a QWidget? For example, Windows can use the gray rectangle when you move a window, while an X11 setup with Compiz can use Wobbly Windows. On X11(Ubuntu 7.10), moving the window by just using:


void myapp::mousePressEvent(QMouseEvent *event) {
if (event->button() == Qt::LeftButton) {
dragPosition = event->globalPos() - frameGeometry().topLeft();
event->accept();
}
}

void myapp::mouseMoveEvent(QMouseEvent *event) {
if (event->buttons() & Qt::LeftButton) {
move(event->globalPos() - dragPosition);
event->accept();
}
}


makes it directly paint every time it is dragged, however moving it while pressing and holding the Alt-key yields the wobbly effect. Is there any way I can natively move the window without requiring the user to, for example, hold the Alt key, or is this out of the question?

Thanks in advance ~codeslicer

wysota
17th February 2008, 19:15
You can probably send an X11 event for moving a window. The wobbly effect (or any other) comes from the window manager - if you want it to be present, you have to move the window through the window manager (for example by holding alt or by dragging the window decoration).

codeslicer
17th February 2008, 20:40
Ok... that's exactly what I said. :eek:
How would I send a command to the window manager, does it have to be platform-dependent or can there be a platform independent way too? :confused:

wysota
17th February 2008, 22:08
As I already said, you need to send an X11 event to the window and hopefully that will go through the window manager.