PDA

View Full Version : Can not resize the window(QGLWidget) after using QCursor::setPos()



pmohod
2nd July 2010, 08:00
Dear all,

I am using Qt-4.6.2 in my application.
I have created a class(ImgMatchTex) inherited from QGLWidget.
Now when I am using QCursor::setPos(int, int) function to set the cursor position.
But after using it, it is giving a problem while resizing the window.
I am not able to increase the height of the window. Event->size().height() remains to constant(zero) even if I try to increase the window height,
and this is due to QCursor::setPos(int, int) function. When I comment this line , it works fine.
Could anyone know reason behind such a abnormal behaviour.




void ImgMatchTex::resizeEvent (QResizeEvent *Event) // Derived form QGLWidget.

{

makeOverlayCurrent();
resizeOverlayGL (Event->size().width(), Event->size().height() );

makeCurrent();
resizeGL (Event->size().width(), Event->size().height() );

QPoint GWinCent = mapToGlobal (QPoint(width()/2, height()/2));
QCursor::setPos (GWinCent.x(), GWinCent.y());

}

agathiyaa
2nd July 2010, 19:47
You should not change the cursor pos in resize event. The reason behind this is simple. You need a pointer/cursor to do resize or any mouse move operation. You are moving the cursor to the center of the window while you resize which in turn resizes your widget to the cursors(moved) location and so on.. until height =0.