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. Get x y z of a Cursor?
Forum Updated to NodeBB v4.3 + New Features

Get x y z of a Cursor?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 608 Views 3 Watching
  • 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.
  • G Offline
    G Offline
    giusirux
    wrote on last edited by
    #1

    Hi everyone,
    I am writing a simple application that can move objects in STL format in three-dimensional space. In this regard, I looked in the Qt documentation and there is the QCursor class which allows me to obtain the x and y coordinates. I wish I could also detect the z coordinate. Is there a class that I can use? I'm using C++, anyway

    I'm really new to Qt, using it only just a month.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You might want to add what you are currently using to show your STL model.

      In any case, QCursor is not meant for 3D modeling, it's really a "desktop" cursor.

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

      G 1 Reply Last reply
      1
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi
        Did you have a look at this ?
        https://doc.qt.io/qt-5/qt3drender-qobjectpicker.html#details

        G 1 Reply Last reply
        1
        • mrjjM mrjj

          Hi
          Did you have a look at this ?
          https://doc.qt.io/qt-5/qt3drender-qobjectpicker.html#details

          G Offline
          G Offline
          giusirux
          wrote on last edited by
          #4

          @mrjj yes
          at the moment, I used void QObjectPicker::moved(Qt3DRender::QPickEvent *pick) where pick contains details of the event. In this, I use setTranslation of Qt3DCore::QTransform like this (using also QCursor):

          globalComponentLightTransform->setTranslation(QVector3D(globalComponentLightTransform->translation().x() + (QCursor::pos().x()-m_storedMousePosition.x()),
                                                           globalComponentLightTransform->translation().y() + (m_storedMousePosition.y()-QCursor::pos().y()),
                                                           globalComponentLightTransform->translation().z()));
          

          QCursor::pos().z() doesn't exist as you know

          mrjjM 1 Reply Last reply
          0
          • G giusirux

            @mrjj yes
            at the moment, I used void QObjectPicker::moved(Qt3DRender::QPickEvent *pick) where pick contains details of the event. In this, I use setTranslation of Qt3DCore::QTransform like this (using also QCursor):

            globalComponentLightTransform->setTranslation(QVector3D(globalComponentLightTransform->translation().x() + (QCursor::pos().x()-m_storedMousePosition.x()),
                                                             globalComponentLightTransform->translation().y() + (m_storedMousePosition.y()-QCursor::pos().y()),
                                                             globalComponentLightTransform->translation().z()));
            

            QCursor::pos().z() doesn't exist as you know

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @giusirux
            QCursor is for 2d so that expected.

            1 Reply Last reply
            0
            • SGaistS SGaist

              Hi,

              You might want to add what you are currently using to show your STL model.

              In any case, QCursor is not meant for 3D modeling, it's really a "desktop" cursor.

              G Offline
              G Offline
              giusirux
              wrote on last edited by giusirux
              #6

              Yes, unfortunately for me
              I need a class that could also read the z coordinate when I pass the cursor over the STL image so I can also move it according to this size.
              Any suggestions?

              EDIT: I was wrong to answer, sorry
              for @SGaist I used something like that https://forum.qt.io/topic/85670/how-to-load-an-stl-file-using-qmesh .

              I added a piece of code where I used setTranslation of Qt3DCore::QTransform

              1 Reply Last reply
              0

              • Login

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