Some problems with drawLine function
-
wrote on 10 Nov 2020, 12:28 last edited by
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)
-
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)
@Shagohod2000 Please show how you're drawing (show the code)
-
@Shagohod2000 Please show how you're drawing (show the code)
wrote on 10 Nov 2020, 12:41 last edited by@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 -
wrote on 10 Nov 2020, 13:01 last edited by
-
@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@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? -
@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?wrote on 19 Nov 2020, 10:46 last edited by@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.