how can i restrict a widget to move beyond the task bar (in windows) and menubar(OSX)
there are widgets in my app which are derived from a custom widget in my app. now i want the widgets not to move beyond the visible screen area.because if it moves beyond that the user will not be able to drag it back and close it through close button.
how to achieve that. I tried to do that as in following code in the event filter of the custom widget:
Code:
//check that the new position is with in available range
QRect desktopRect
= desktop
->availableGeometry
();
if(desktopRect.contains(keyEvent->globalPos())){
this->move(this->pos() + (keyEvent->globalPos() - mLastMousePosition));
mLastMousePosition = keyEvent->globalPos();
return true;
}
This is not working. Where I am doing wrong.
Pls, show me a way to acheive this.
Thanks.
Re: how can i restrict a widget to move beyond the task bar (in windows) and menubar(
Quote:
because if it moves beyond that the user will not be able to drag it back and close it through close button.
But how can that happen?
In order to drag the window outside the desktop your mouse needs to be able to get out of the desktop, and that is not possible (at least not in the normal case).
So, a situation that your widget/window comes out of the reach of your mouse is not possible...
Or please explain how it is.