Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Solved how to conert QpointF into int

    General and Desktop
    3
    6
    1194
    Loading More Posts
    • 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
      ShrikantAmbade last edited by

      hello everyone,

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

      D 1 Reply Last reply Reply Quote 0
      • Yves Maurischat
        Yves Maurischat last edited by Yves Maurischat

        Try this:

        int x = yourPointF.toPoint().x()
        int y = yourPointF.toPoint().y() 
        
        S 1 Reply Last reply Reply Quote 0
        • Yves Maurischat
          Yves Maurischat last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • D
            DRoscoe @ShrikantAmbade last edited by

            @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 Reply Quote 0
            • S
              ShrikantAmbade @Yves Maurischat last edited by

              @Yves-Maurischat Thanks :)

              1 Reply Last reply Reply Quote 0
              • S
                ShrikantAmbade @DRoscoe last edited by

                @DRoscoe Thanks

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post