Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Unable to map QCursor::pos() to widget coordinates
QtWS25 Last Chance

Unable to map QCursor::pos() to widget coordinates

Scheduled Pinned Locked Moved Unsolved General and Desktop
qcursorqpointqrect
6 Posts 3 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dariusz
    wrote on 4 Apr 2020, 22:22 last edited by
    #1

    Hey

    I'm struggling to map my cursor to widget coordinates to detect when user move it over the window. When I run a test I get this :

        qDebug() << view->isVisible() << view->geometry().contains(view->mapFromGlobal(QCursor::pos())) << QCursor::pos() << view->mapFromGlobal(QCursor::pos()) << view->geometry();
    
    true false QPoint(527,121) QPoint(73,69) QRect(454,29 2986x1362) 
    

    The mouse is in left-upper corner of widget, the second QPoint() coordinate remain valid. But when I do contains() on geometry it returns fals after mapping...
    How can I properly do this test?

    TIA

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 4 Apr 2020, 22:36 last edited by
      #2

      Hi
      What is View ?

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Dariusz
        wrote on 4 Apr 2020, 22:37 last edited by
        #3

        Hey
        Its as below :
        QMainWindow > QDockWidget > QScrollArea > QWidget > QLayout > QWidget::createWindowContainer(QOpenGLWindow). < view is the openGLWindow.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 5 Apr 2020, 19:19 last edited by
          #4

          Hi,

          Can you tell us what you want to do with when your mouse goes over that widget ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          D 1 Reply Last reply 9 Apr 2020, 08:31
          1
          • S SGaist
            5 Apr 2020, 19:19

            Hi,

            Can you tell us what you want to do with when your mouse goes over that widget ?

            D Offline
            D Offline
            Dariusz
            wrote on 9 Apr 2020, 08:31 last edited by
            #5

            @SGaist said in Unable to map QCursor::pos() to widget coordinates:

            Hi,

            Can you tell us what you want to do with when your mouse goes over that widget ?

            I have eventFilter installed n qApp, when user press a key, I emit that in a signal, and any widget that is interested in that key, checks if at the time mouse is over it and then acts properly. It seems to be a "hiccup" with qopenglwindow, treeviews appear to work fine.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 9 Apr 2020, 18:37 last edited by
              #6

              Then please provide a minimal compilable example that shows the behaviour.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              1/6

              4 Apr 2020, 22:22

              • Login

              • Login or register to search.
              1 out of 6
              • First post
                1/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved