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. Incrementing the length of a QLineF in the negative direction?
QtWS25 Last Chance

Incrementing the length of a QLineF in the negative direction?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 828 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.
  • J Offline
    J Offline
    jh224
    wrote on last edited by
    #1

    The documentation seems to be spotty on this. Below is how I did it. Is this the correct way?

    @
    QLineF refLine(100,100, 500,500);
    QLineF perpLine = refLine.normalVector(); //create a perpendicular line to the refLine
    perpLine.setLength(-1); //this seems to set it in the negative direction and it stays in the negative direction

    for(int i = 0; i < 50; i++)
    {
    perpLine.setLength(perpLine.Length + 1); // this will increment perpLine in a negative direction
    }

    @

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      i read the docs of QLineF::setLength() pretty clear:
      [quote]
      Sets the length of the line to the given length. QLineF will move the end point (p2) of the line to give the line its new length
      [/quote]

      The following code would rotate the line by 180° (around p1):
      @
      QLineF line(100,100, 500,500);
      line.setLength( - line.length() );
      @

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jh224
        wrote on last edited by
        #3

        Thanks for the reply. I always find Qt documentation to be top notch. I'm having trouble inferring from the documentation on this topic to mean negative numbers will invert/rotate the line.

        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