PDA

View Full Version : Obtaining the relative position of the widget in the viewport in QScrollArea class



Dark_Tower
14th April 2006, 08:34
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

jacek
14th April 2006, 10:34
QCursor::pos() and QWidget::mapFromGlobal()

Dark_Tower
14th April 2006, 11:20
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?

jacek
14th April 2006, 11:33
What do you think?
I think that you should first try it and then ask.