Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. What "C/C++ type" ( int, char,QStringe etc ...? ) is "pos()"?
Qt 6.12 LTS is out! See what's new in the release blog

What "C/C++ type" ( int, char,QStringe etc ...? ) is "pos()"?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 783 Views 2 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by Anonymous_Banned275
    #1
    This post is deleted!
    Christian EhrlicherC 1 Reply Last reply
    0
    • A Anonymous_Banned275

      This post is deleted!

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @AnneRanch said in What "type" is "pos()"?:

      event->pos();

      Of what type is event and what Qt version do you use? If you know the type of event and your Qt version you can search the Qt documentation for it.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      A 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        @AnneRanch said in What "type" is "pos()"?:

        event->pos();

        Of what type is event and what Qt version do you use? If you know the type of event and your Qt version you can search the Qt documentation for it.

        A Offline
        A Offline
        Anonymous_Banned275
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • Paul ColbyP Offline
          Paul ColbyP Offline
          Paul Colby
          wrote on last edited by
          #4

          Hi @AnneRanch,

          As @Christian-Ehrlicher replied, it depends on what type event is, and the version of Qt.

          Given you're naming the result dragStartPosition, I'm guessing event is either derived from QPointerEvent, QMouseEvent, or QDropEvent (including QDragEnterEvent). For all of those, *::pos() returns QPoint on Qt5, but in Qt6 the function is *::position() instead, and returns QPointF. ie

          #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
          const QPoint dragStartPosition = event->pos();
          #else
          const QPointF dragStartPosition = event->position();
          #endif
          

          To be any more specific than that, you'll need to tell use what type event is, and the Qt version.

          Cheers.

          PS You could also use auto.

          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
          • Unsolved