Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Chinese
  4. Some problems with drawLine function
Forum Update on Monday, May 27th 2025

Some problems with drawLine function

Scheduled Pinned Locked Moved Unsolved Chinese
6 Posts 2 Posters 989 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.
  • S Offline
    S Offline
    Shagohod2000
    wrote on 10 Nov 2020, 12:28 last edited by
    #1

    Hi~ o( ̄▽ ̄)ブ,we are the undergraduates from china and we use Qt to do something about UWB. But now we meet some problems in developing a function to draw a Geo-fencing. We use the drawline-function to draw a line between the two points, but it seems a little bit strange when it finished. The line can't arrive another point (#°Д°),it really astonish us. We did a lot to research this problem, but we got nothing ( ̄_ ̄|||). Emmm, so we decide to ask for helps from the Qt Forum. We would appreciate a lot if someone give out some useful adviceヾ(≧▽≦*)o. (Please ignore our poor English)

    J 1 Reply Last reply 10 Nov 2020, 12:32
    0
    • S Shagohod2000
      10 Nov 2020, 12:28

      Hi~ o( ̄▽ ̄)ブ,we are the undergraduates from china and we use Qt to do something about UWB. But now we meet some problems in developing a function to draw a Geo-fencing. We use the drawline-function to draw a line between the two points, but it seems a little bit strange when it finished. The line can't arrive another point (#°Д°),it really astonish us. We did a lot to research this problem, but we got nothing ( ̄_ ̄|||). Emmm, so we decide to ask for helps from the Qt Forum. We would appreciate a lot if someone give out some useful adviceヾ(≧▽≦*)o. (Please ignore our poor English)

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 10 Nov 2020, 12:32 last edited by
      #2

      @Shagohod2000 Please show how you're drawing (show the code)

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply 10 Nov 2020, 12:41
      0
      • J jsulm
        10 Nov 2020, 12:32

        @Shagohod2000 Please show how you're drawing (show the code)

        S Offline
        S Offline
        Shagohod2000
        wrote on 10 Nov 2020, 12:41 last edited by
        #3

        @jsulm
        void GraphicsView::drawFence(QPainter *painter)
        {
        painter->drawLine(RTLSDisplayApplication::viewSettings()->setUpperLeftValueX(), RTLSDisplayApplication::viewSettings()->setUpperLeftValueY(), RTLSDisplayApplication::viewSettings()->setUpperRightValueX(), RTLSDisplayApplication::viewSettings()->setUpperRightValueY());
        painter->drawLine(RTLSDisplayApplication::viewSettings()->setUpperLeftValueX(), RTLSDisplayApplication::viewSettings()->setUpperLeftValueY(), RTLSDisplayApplication::viewSettings()->setLowerLeftValueX(), RTLSDisplayApplication::viewSettings()->setLowerLeftValueY());
        painter->drawLine(RTLSDisplayApplication::viewSettings()->setLowerLeftValueX(), RTLSDisplayApplication::viewSettings()->setLowerLeftValueY(), RTLSDisplayApplication::viewSettings()->setLowerRightValueX(), RTLSDisplayApplication::viewSettings()->setLowerRightValueY());
        painter->drawLine(RTLSDisplayApplication::viewSettings()->setLowerRightValueX(), RTLSDisplayApplication::viewSettings()->setLowerRightValueY(), RTLSDisplayApplication::viewSettings()->setUpperRightValueX(), RTLSDisplayApplication::viewSettings()->setUpperRightValueY());

        }
        we use the void QPainter::drawLine(int x1, int y1, int x2, int y2) to do it

        J 1 Reply Last reply 10 Nov 2020, 13:09
        0
        • S Offline
          S Offline
          Shagohod2000
          wrote on 10 Nov 2020, 13:01 last edited by
          #4

          Qt false.PNG This is the wrong state
          Qt right.PNG This is the right state
          We just draw the fence across the four points

          1 Reply Last reply
          0
          • S Shagohod2000
            10 Nov 2020, 12:41

            @jsulm
            void GraphicsView::drawFence(QPainter *painter)
            {
            painter->drawLine(RTLSDisplayApplication::viewSettings()->setUpperLeftValueX(), RTLSDisplayApplication::viewSettings()->setUpperLeftValueY(), RTLSDisplayApplication::viewSettings()->setUpperRightValueX(), RTLSDisplayApplication::viewSettings()->setUpperRightValueY());
            painter->drawLine(RTLSDisplayApplication::viewSettings()->setUpperLeftValueX(), RTLSDisplayApplication::viewSettings()->setUpperLeftValueY(), RTLSDisplayApplication::viewSettings()->setLowerLeftValueX(), RTLSDisplayApplication::viewSettings()->setLowerLeftValueY());
            painter->drawLine(RTLSDisplayApplication::viewSettings()->setLowerLeftValueX(), RTLSDisplayApplication::viewSettings()->setLowerLeftValueY(), RTLSDisplayApplication::viewSettings()->setLowerRightValueX(), RTLSDisplayApplication::viewSettings()->setLowerRightValueY());
            painter->drawLine(RTLSDisplayApplication::viewSettings()->setLowerRightValueX(), RTLSDisplayApplication::viewSettings()->setLowerRightValueY(), RTLSDisplayApplication::viewSettings()->setUpperRightValueX(), RTLSDisplayApplication::viewSettings()->setUpperRightValueY());

            }
            we use the void QPainter::drawLine(int x1, int y1, int x2, int y2) to do it

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 10 Nov 2020, 13:09 last edited by
            #5

            @Shagohod2000 said in Some problems with drawLine function:

            setUpperLeftValueX()

            What do these set* methods do? Why are they called set*? Set is usually used to set some value, not to get it.
            Back to your problem: check your coordinates - are those as expected?

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            S 1 Reply Last reply 19 Nov 2020, 10:46
            0
            • J jsulm
              10 Nov 2020, 13:09

              @Shagohod2000 said in Some problems with drawLine function:

              setUpperLeftValueX()

              What do these set* methods do? Why are they called set*? Set is usually used to set some value, not to get it.
              Back to your problem: check your coordinates - are those as expected?

              S Offline
              S Offline
              Shagohod2000
              wrote on 19 Nov 2020, 10:46 last edited by
              #6

              @jsulm The primary cause of our error is the misuse of the integer parameter rather than float parameter in the drawling function. Sorry to reply so late and we really appreciate a lot for your help.

              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