Results 1 to 2 of 2

Thread: cursor

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default cursor

    hi, when I click on qglwiget I need put cursor at middle of widget; this isn't working!
    Is this ok? thanks
    Qt Code:
    1. //paintGL of myWidget class
    2. QCursor::setPos(QPoint(this->x()+this->width()/2, this->y()+this->height()/2 ));
    To copy to clipboard, switch view to plain text mode 
    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: cursor

    Quote Originally Posted by mickey
    hi, when I click on qglwiget I need put cursor at middle of widget; this isn't working!
    Is this ok?
    Unfortunately, not.

    Qt docs say:
    void QCursor::setPos ( int x, int y ) [static]
    Moves the cursor (hot spot) to the global screen position (x, y).
    You can call QWidget::mapToGlobal() to translate widget coordinates to global screen coordinates.
    But you use coordinates relative to the parent widget:
    int QWidget::x () const
    Returns the x coordinate of the widget relative to its parent including any window frame. See the "x" property for details.
    (it would work if the widget was a top level widget).

    This should work:
    Qt Code:
    1. QCursor::setPos( mapToGlobal( QPoint( width()/2, height()/2 ) ) );
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 5
    Last Post: 23rd May 2006, 11:40
  2. setting cursor problem in QTextEdit
    By jyoti kumar in forum Qt Programming
    Replies: 3
    Last Post: 19th May 2006, 08:17
  3. ummm...cursor not changing...
    By nupul in forum Qt Programming
    Replies: 7
    Last Post: 4th May 2006, 16:57
  4. QLineEdit and QScrollBar
    By Sarma in forum Qt Programming
    Replies: 4
    Last Post: 8th March 2006, 08:07
  5. QTextEdit Qt4: simple question
    By TheKedge in forum Qt Programming
    Replies: 4
    Last Post: 18th January 2006, 12:03

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.