首页| 论坛| 消息

标题:qcustomplot 怎么更改横轴为时间轴
作者:15927174837
日期:2016-05-10 16:58
内容:

要可配置的更改,可切换时间轴和数值轴


#1 [15927174837 05-10 18:24]
求大神帮助啊
#2 [xiaoniede 05-10 21:54]
///设置数值类型的坐标轴
ui->customplot->xAxis->setTickLabelType(QCPAxis::ltNumber);
ui->customplot->xAxis->setNumberFormat("fb");
ui->customplot->xAxis->setNumberPrecision(0);///小数点位数
ui->customplot->xAxis->setRange(0,1000);
ui->customplot->replot();
///设置时间类型的坐标轴
double dCurSeconds = QDateTime::currentDateTimeUtc().toTime_t();
double dRangeLower = dCurSeconds-3600;
double dRangeHight = dCurSeconds;
ui->customplot->xAxis->setTickLabelType(QCPAxis::ltDateTime);
ui->customplot->xAxis->setRange(dRangeLower, dRangeHight);
ui->customplot->xAxis->setDateTimeFormat("hh:mm");
ui->customplot->xAxis->setDateTimeSpec(Qt::UTC);
ui->customplot->replot();
以上为实例代码,你可以试一下。
#3 回 xiaoniede 的帖子 [15927174837 05-10 22:27]
xiaoniede:///设置数值类型的坐标轴
    ui->customplot->xAxis->setTickLabelType(QCPAxis::ltNumber);
    ui->customplot->xAxis->setNumberFormat("fb");
    ui->customplot->xAxis-&g .. (2016-05-10 21:54) 
这个不能切换啊,比如说原来是这个类型:QCPAxis::ltNumber,就不能切换到QCPAxis::ltDateTime?2个不能相互切换啊
#4 [xiaoniede 05-11 10:08]
可以!再次设置之后要 ui->customplot->replot(); 。
#5 回 xiaoniede 的帖子 [15927174837 05-12 14:32]
xiaoniede:可以!再次设置之后要 ui->customplot->replot(); 。 (2016-05-11 10:08) 
这个用了,但是没用啊!!!
所以现在我将x轴label用时间换成相应的qstring了!!
你画过柱状图没有,为什么有些柱子不能显示啊

<< 1 2 >> (1/2)

回复 发表
主题 版块