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. QLine to QRect with Margin
Qt 6.11 is out! See what's new in the release blog

QLine to QRect with Margin

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 437 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.
  • DonCoderD Offline
    DonCoderD Offline
    DonCoder
    wrote on last edited by DonCoder
    #1

    line2rect.JPG

    I have a QLine with A(a0,b0) and B(a1,b1) , where x is a margin. So i should find out final rect coordinates which formed by adding margin to the line AB.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Create a QTransform to move A to 0,0 (translate) and B to 0,y (rotate, you can get the rotation from QLineF::angle()). Apply the transform to your line.
      Then you can calculate the margin points and transform them back with your calculated transform from above.

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

      1 Reply Last reply
      1
      • DonCoderD Offline
        DonCoderD Offline
        DonCoder
        wrote on last edited by
        #3

        I am new to QTransform, will you eloborate your answer please

        Christian EhrlicherC 1 Reply Last reply
        0
        • DonCoderD DonCoder

          I am new to QTransform, will you eloborate your answer please

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

          @DonCoder said in QLine to QRect with Margin:

          I am new to QTransform,

          See the documentation - a little bit of matematics.

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

          1 Reply Last reply
          1

          • Login

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