QCPItemLine is being paint automatically

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


QCPItemLine is being paint automatically



Im trying using QCustomPlot in my gui



MainWindow.h


public:
void initArrow();

private:
QCustomPlot* grid;
QCPItemLine* arrow;



MainWindow.cpp


void MainWindow::initArrow() {
arrow = new QCPItemLine(ui->grid);
QPen pen(Qt::red);
pen.setWidth(4);

arrow->setPen(pen);
arrow->setHead(QCPLLineEnding::esLineArrow);
arrow->setHead(QCPLLineEnding::esDisc);
}



in this situation i'm playing the program, i resize the window and i see an arrow on the plot with coordinates (0,0) and (1,1).
this is the code
.
I didnt use replot!
I didnt use start!
I didnt use end!



in addition, when i will understand what is the problem I'm asking what is the correct way to draw a line when i'm trying to draw above other graph.



normally if I'm using points it will be like:


QVector<double> x;
QVector<double> y;
ui->grid->graph(number)->setData(x,y);
ui->grid->graph(number)->replot();



but I cant do setData with a line and its not related to some graph so i can i Draw the line on a specefic graph??





what is ui->grid?
– eyllanesc
1 hour ago




ui->grid





ok. in MainWindow i have QCustomPlot* grid. i want to make a function with x_start, y_start, x_end, y_end and draw an arrow accordingly
– asaf anter
1 hour ago







what is your goal?
– eyllanesc
1 hour ago





for example drawLine(1,1,4,5) will draw an arrow between those coordinates
– asaf anter
1 hour ago





If you do not explain clearly what you want and provide a decent Minimal, Complete, and Verifiable example unfortunately I can not help you :)
– eyllanesc
41 mins ago









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived