Results 1 to 2 of 2

Thread: Can not resize the window(QGLWidget) after using QCursor::setPos()

  1. #1
    Join Date
    Feb 2007
    Posts
    4
    Qt products
    Qt3 Qt/Embedded
    Platforms
    Unix/X11

    Default Can not resize the window(QGLWidget) after using QCursor::setPos()

    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.

    Qt Code:
    1. void ImgMatchTex::resizeEvent (QResizeEvent *Event) // Derived form QGLWidget.
    2.  
    3. {
    4.  
    5. makeOverlayCurrent();
    6. resizeOverlayGL (Event->size().width(), Event->size().height() );
    7.  
    8. makeCurrent();
    9. resizeGL (Event->size().width(), Event->size().height() );
    10.  
    11. QPoint GWinCent = mapToGlobal (QPoint(width()/2, height()/2));
    12. QCursor::setPos (GWinCent.x(), GWinCent.y());
    13.  
    14. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jun 2010
    Location
    India
    Posts
    50
    Thanks
    1
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Can not resize the window(QGLWidget) after using QCursor::setPos()

    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.
    Last edited by agathiyaa; 2nd July 2010 at 19:59.

Similar Threads

  1. QCursor::setPos() fails with x server fatal error
    By Arnaldo Diniz in forum Qt Programming
    Replies: 3
    Last Post: 2nd December 2010, 23:45
  2. QCursor::setPos() - doesn't work
    By Piskvorkar in forum Qt Programming
    Replies: 0
    Last Post: 21st March 2010, 13:24
  3. QCursor::setPos makes cursor inactive for ~200ms
    By trhaynes in forum Qt Programming
    Replies: 2
    Last Post: 30th July 2009, 15:07
  4. Why QCursor setPos() dosen't work here?
    By kar98k in forum Qt Programming
    Replies: 8
    Last Post: 1st June 2007, 12:52
  5. QCursor::setPos
    By Levon Nikoghosyan in forum Qt Programming
    Replies: 1
    Last Post: 26th December 2006, 08:16

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.