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. how to conert QpointF into int
Forum Updated to NodeBB v4.3 + New Features

how to conert QpointF into int

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 1.8k Views 1 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.
  • S Offline
    S Offline
    ShrikantAmbade
    wrote on last edited by
    #1

    hello everyone,

    How can I convert QpointF into int x and int y
    many thanks

    D 1 Reply Last reply
    0
    • Yves MaurischatY Offline
      Yves MaurischatY Offline
      Yves Maurischat
      wrote on last edited by Yves Maurischat
      #2

      Try this:

      int x = yourPointF.toPoint().x()
      int y = yourPointF.toPoint().y() 
      
      S 1 Reply Last reply
      0
      • Yves MaurischatY Offline
        Yves MaurischatY Offline
        Yves Maurischat
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • S ShrikantAmbade

          hello everyone,

          How can I convert QpointF into int x and int y
          many thanks

          D Offline
          D Offline
          DRoscoe
          wrote on last edited by
          #4

          @ShrikantAmbade You can use the accessor methods of the QPointF object to obtain the X and Y coordinates contained within:

          qreal & QPointF::rx()
          qreal & QPointF::ry()

          qreal is a typedef of a double (float on ARM-based platforms)

          You can then easily convert them to integers. Its up to you how you want to handle any fractional portion

          S 1 Reply Last reply
          0
          • Yves MaurischatY Yves Maurischat

            Try this:

            int x = yourPointF.toPoint().x()
            int y = yourPointF.toPoint().y() 
            
            S Offline
            S Offline
            ShrikantAmbade
            wrote on last edited by
            #5

            @Yves-Maurischat Thanks :)

            1 Reply Last reply
            0
            • D DRoscoe

              @ShrikantAmbade You can use the accessor methods of the QPointF object to obtain the X and Y coordinates contained within:

              qreal & QPointF::rx()
              qreal & QPointF::ry()

              qreal is a typedef of a double (float on ARM-based platforms)

              You can then easily convert them to integers. Its up to you how you want to handle any fractional portion

              S Offline
              S Offline
              ShrikantAmbade
              wrote on last edited by
              #6

              @DRoscoe Thanks

              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