Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I want to ask a question about qcustomplot. How can i change itemLine position according to Slider? (like x = a)
#include "itemline.h"
#include "ui_itemline.h"
#include "qcustomplot.h"
itemLine::itemLine(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::itemLine)
ui->setupUi(this);
QCPItemLine *item = new QCPItemLine(ui->customPlot);
ui->customPlot->addItem(item);
item->setPen(QPen(Qt::red));
item->start->setCoords(1,0);
item->end->setCoords(1,5);
connect(ui->horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(horzSliderChanged(int)));
itemLine::~itemLine()
delete ui;
void itemLine::horzSliderChanged(int value)
// how can i change item position acording to horizontalSlider, like "x = a" line ?
First you should keep the pointer to QCPItemLine
as a class member. After that horzSliderChanged
slot could be like :
void itemLine::horzSliderChanged(int value)
item->start->setCoords(value,0);
item->end->setCoords(value,5);
ui->customPlot->replot();
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.