Results 1 to 8 of 8

Thread: mouseEvent in QScrollArea giving wrong position ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: mouseEvent in QScrollArea giving wrong position ?

    Quote Originally Posted by barnabyr
    Although the mapFromParent solution makes no sense to me ...

    "From parent" would imply that .. the position in e->pos() is in parent
    coordinates which was what I was finding to be true. ( ie. the y coordinate was
    relative to the parent window not the scroll area) BUT .. the event handler
    is part of my QScrollArea .. not my parent window, so why wasn't
    e->pos() passed as the correct position in the first place ?
    "the parent" is probably the QScrollArea widget (the widget which handles the event), and you want its viewport, thus you have to map from the scroll area widget to its "canvas" coordinates. That's exactly the same what my solution does (seems that Trolls use the scrollbar version in their examples, at least the one I've seen -- namely the pie view example).

    And Wysota thanks for the reminder about contextMenuEvent . I guess I assumed it wouldn't be available ...
    Just remember that context menus can be handled in three different ways in Qt4. Choose the one which suits you best.

  2. #2
    Join Date
    Jul 2009
    Location
    China,Shanghai
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: mouseEvent in QScrollArea giving wrong position ?

    Please use mapToXXX or mapFromXXX to solve the problem.

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
  •  
Qt is a trademark of The Qt Company.