Gradient straight line.
Hello everyone. I have some real time plots and I'm trying to draw a QCLItemStraightLine object on the background with a gradient QBrush.
I've managed to draw the object, my problem is with the gradient start and stop, I'm unable to get the proper coordinates for the width of my line, which is now defined by a fourth of the CustomPlot Object height.
So, my gradient never starts and stops were it's supposed to. Please, help.
Previously I tried a QCPItemRect, but since it's a real time plot and has to be reploted, the item gor reploted and moved with the timeline.
Here's my code for drawing the straight line and a screen capture of my result.
double yPosition=5.0*0.198; double myHeight=height(); unsigned int lineWidth=static_cast<unsigned int>(myHeight/4.0); double gradStartY=yPosition+lineWidth*0.0053; double gradStopY=yPosition-lineWidth*0.0053; QPoint gradStart(static_cast<int>((m_xmax-m_xmin)/2.0),static_cast<int>(gradStartY)); QPoint gradStop(static_cast<int>((m_xmax-m_xmin)/2.0),static_cast<int>(gradStopY)); lgrad.setStart(gradStart); lgrad.setFinalStop(gradStop); m_redline=new QCPItemStraightLine(m_customPlot); m_redline->setPen(QPen(QBrush(lgrad),lineWidth,Qt::SolidLine)); m_redline->point1->setCoords(m_xmin,yPosition); m_redline->point2->setCoords(m_xmax,yPosition); QString layerRedLine("redLine"); m_customPlot->addLayer(layerRedLine,m_customPlot->layer("grid"),QCustomPlot::limAbove); m_redline->setLayer(layerRedLine);