1 Star 0 Fork 20

bingou0/Qtweiniu

forked from 1ndu5try/Qtweiniu 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
tagaxis.cpp 1.52 KB
一键复制 编辑 原始数据 按行查看 历史
unknown 提交于 2022-08-04 19:07 . tijao
#include "tagaxis.h"
TagAxis::TagAxis(QCPAxis *parentAxis) : QObject(parentAxis),
mAxis(parentAxis)
{
mDummyTracerY1 = new QCPItemTracer(mAxis->parentPlot());
mDummyTracerY1->setVisible(true);
mDummyTracerY1->position->setTypeX(QCPItemPosition::ptAxisRectRatio);//QCPItemPosition::ptPlotCoords
mDummyTracerY1->position->setTypeY(QCPItemPosition::ptPlotCoords);
mDummyTracerY1->position->setAxisRect(mAxis->axisRect());
mDummyTracerY1->position->setAxes(0, mAxis);
mLabelY1 = new QCPItemText(mAxis->parentPlot());
mLabelY1->setLayer("overlay");
mLabelY1->setClipToAxisRect(false);
mLabelY1->setPadding(QMargins(3, 0, 3, 0));
mLabelY1->setBrush(QBrush(Qt::white));
mLabelY1->setPen(QPen(Qt::blue));
mLabelY1->setPositionAlignment(Qt::AlignRight|Qt::AlignVCenter);
mLabelY1->position->setTypeX(QCPItemPosition::ptAxisRectRatio);//QCPItemPosition::ptPlotCoords
mLabelY1->position->setTypeY(QCPItemPosition::ptPlotCoords);
}
TagAxis::~TagAxis()
{
if (mDummyTracerY1)
mDummyTracerY1->parentPlot()->removeItem(mDummyTracerY1);
if (mLabelY1)
mLabelY1->parentPlot()->removeItem(mLabelY1);
}
void TagAxis::setPen(const QPen &pen)
{
mLabelY1->setPen(pen);
}
void TagAxis::setBrush(const QBrush &brush)
{
mLabelY1->setBrush(brush);
}
void TagAxis::setTextY1(const QString &text)
{
mLabelY1->setText(text);
}
void TagAxis::updatePosition(double valueY1)
{
mDummyTracerY1->position->setCoords(0, valueY1);
mLabelY1->position->setCoords(0,valueY1);
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/bingou0/qtweiniu.git
git@gitee.com:bingou0/qtweiniu.git
bingou0
qtweiniu
Qtweiniu
master

搜索帮助