本文整理汇总了C++中QCustomPlot::setInteraction方法的典型用法代码示例。如果您正苦于以下问题:C++ QCustomPlot::setInteraction方法的具体用法?C++ QCustomPlot::setInteraction怎么用?C++ QCustomPlot::setInteraction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QCustomPlot
的用法示例。
在下文中一共展示了QCustomPlot::setInteraction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupChart
void ChartPage::setupChart()
{
this->buildingChart=true;
QCustomPlot *customPlot = ui->chartBlock;
customPlot->setInteraction(QCP::iRangeDrag, true);
customPlot->setInteraction(QCP::iSelectPlottables, true);
customPlot->setInteraction(QCP::iSelectItems, true);
customPlot->setInteraction(QCP::iRangeZoom, true);
customPlot->legend->setVisible(true);
customPlot->legend->setFont(QFont("Helvetica",9));
// set locale to english, so we get english decimal separator:
customPlot->setLocale(QLocale(QLocale::English, QLocale::UnitedKingdom));
// create graph and assign data to it:
customPlot->addGraph();
customPlot->graph(0)->setName("Difficulty");
// customPlot->graph(0)->setData(x, y);
// give the axes some labels:
customPlot->xAxis->setLabel("Date");
customPlot->yAxis->setLabel("Difficulty");
customPlot->legend->setSelectableParts(QCPLegend::spItems);
customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes | QCP::iSelectLegend | QCP::iSelectPlottables);
customPlot->axisRect()->setupFullAxesBox();
customPlot->xAxis->setTickLabelType(QCPAxis::ltDateTime);
customPlot->xAxis->setDateTimeFormat("dd/MM/yyyy");
customPlot->xAxis->setAutoTickCount(5);
//customPlot->yAxis->setAutoTickCount(5);
// set axes ranges, so we see all data:
customPlot->yAxis->setRange(-0.1, 3);
ClientModel *model = this->clientModel;
// generate some data:
QVector<double> x(1000), y(1000); //, y1(50000);
int maxBlocks;
maxBlocks = model->getNumBlocks();
if (maxBlocks > 1000)
{
maxBlocks=1000;
}
int i = 0;
if (maxBlocks > 0) {
for (i = 0; i < maxBlocks; i++)
{
CBlock blk = model->getBlock(i);
CBlockIndex* cIndex = model->getBlockIndex(i);
x[i]=blk.GetBlockTime();
y[i]=model->getDiff(cIndex);
}
customPlot->graph(0)->setData(x, y);
customPlot->xAxis->setRange(x[i-1]-(60*60*24), x[i-1]);
this->lastBlockHeight = i;
}
customPlot->replot();
this->buildingChart=false;
}