Results 1 to 4 of 4

Thread: Obtaining the relative position of the widget in the viewport in QScrollArea class

  1. #1
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Obtaining the relative position of the widget in the viewport in QScrollArea class

    Hi there, I use a QScrollArea and I would like to know if it's possible to obtain the relative position of the mouse (I missed to specify it in the title of the post) respect the widget inside the scroll area (not the viewport's widget) without having to subclass it (obtaining the position directly from the scroll area class)? Thanks
    Last edited by Dark_Tower; 14th April 2006 at 09:18.

  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: Obtaining the relative position of the widget in the viewport in QScrollArea class

    QCursor::pos() and QWidget::mapFromGlobal()

  3. The following user says thank you to jacek for this useful post:

    Dark_Tower (14th April 2006)

  4. #3
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Obtaining the relative position of the widget in the viewport in QScrollArea clas

    Thanks a lot jacek. I was afraid of using this function ("mapToGlobal") because I don't know if it works with a widget inserted in a scroll area: I don't know how it could manage it internally, I suppose that it has to consult the values of the scroll bars or what's the visible area to make the translation from screen coords to widget coords... What do you think?

  5. #4
    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: Obtaining the relative position of the widget in the viewport in QScrollArea clas

    Quote Originally Posted by Dark_Tower
    What do you think?
    I think that you should first try it and then ask.

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.