hai all,
how can we get the coordinate of desktop when mouse is placed on a particular point of desktop?
Can someone help me ?
hai all,
how can we get the coordinate of desktop when mouse is placed on a particular point of desktop?
Can someone help me ?
QWidget::mapToGlobal() and QDesktopWidget if you like.
We need the cursor position on the desktop while the application is running.
In our project we need to apply magnetic effects on desktop widgets.When we drag the widget to the right edge of the desktop it move to the right edge and hide from the desktop(its working fine in our application). We need the widget to pop- up from the right of the desktop to the left if we slide the mouse on the right edge of the desktop.We need to check whether the current cursor position is on the right edge of desktop. How can we do this?
Qt Code:
{ { qDebug()<<"Mouse Move event...."<<mouseEvent->pos().x()<<mouseEvent->pos().y(); } return false; }To copy to clipboard, switch view to plain text mode
This code works fine inside the widget but don't get the coordinates outside the widget. We need to get the cursor coordinates on desktop
Last edited by vinayaka; 18th January 2012 at 08:51. Reason: updated contents
Either grabMouse() (but then nobody else will receive the events) or periodically poll the cursor position using QCursor::pos(), however this will be inefficient and will probably worsen your user experience. The proper approach would be to hook into the native event system to be notified upon interesting events.
We dont get you?plz specify briefly?The proper approach would be to hook into the native event system to be notified upon interesting events.
Briefly speaking -- use WinAPI.
I'm not sure I've understood you well but I think you want to be able to drag window to the right edge of the desktop and then make it pop from the left, right?
If that's the case then it's simple:If that's not the case then I don't know what you want to achieve.Qt Code:
{ if( mp.x() > dr.right() - 5 ) { dr.moveLeft( 0 ); mp.setX( 0 ); this->move( dr.topLeft() ); } }To copy to clipboard, switch view to plain text mode
I think the requirement is to build a "menu" app that normally is invisible, but slides out from the RHS of the desktop when the mouse pointer is pushed to the RHS of the desktop. Presumably the app will slide back off the RHS of the desktop when the mouse pointer is no longer over it.
It seems to me that a peek at QCursor::pos() every 250ms or so (using QTimer) is the easiest way. If the cursor is against the edge in two consecutive checks then pop up. Elegant? Maybe not.
Another approach might be to leave a (transparent?) borderless, always-on-top widget a few pixels wide on the desktop RHS and look for mouse move events on it.
thank you all for your valuable suggestion.Here I am attaching a sample video that show the interaction of Widget.we need to apply the effects like in video.How can we do the same?
Last edited by vinayaka; 20th January 2012 at 12:39.
So you want a sheet-like behavior. For hiding you can use leaveEvent(), for showing I think Chris has already given you a possible solution.
can anyone please send the sample code for applying these effects into our Widget?
Bookmarks