当前位置:网站首页>轮子1:QCustomPlot初始化模板
轮子1:QCustomPlot初始化模板
2022-07-05 08:31:00 【老赵的博客】
void mainWindow::initTable(QCustomPlot *customPot, QString strX, QString strY)
{
QLinearGradient plotGradient;
plotGradient.setStart(0, 0);
plotGradient.setFinalStop(0, 350);
plotGradient.setColorAt(0, QColor(37, 40, 45));
plotGradient.setColorAt(1, QColor(37, 40, 45));
customPot->setBackground(plotGradient); // 设置背景颜色
QLinearGradient axisRectGradient;
axisRectGradient.setStart(0, 0);
axisRectGradient.setFinalStop(0, 350);
axisRectGradient.setColorAt(0, QColor(37, 40, 45));
axisRectGradient.setColorAt(1, QColor(37, 40, 45));
customPot->axisRect()->setBackground(axisRectGradient); // 设置QCPAxisRect背景颜色
//x
customPot->xAxis->setTicks(true);
customPot->xAxis->setBasePen(QPen(Qt::white, 1)); // 轴线的画笔
customPot->xAxis->setTickPen(QPen(Qt::white, 1)); // 轴刻度线的画笔
customPot->xAxis->setSubTickPen(QPen(Qt::white, 1)); // 轴子刻度线的画笔
customPot->xAxis->setTickLabelColor(Qt::white); // 轴刻度文字颜色
customPot->xAxis->setLabel(strX); // 只有设置了标签,轴标签的颜色才会显示
customPot->xAxis->setLabelColor(Qt::white); // 轴标签颜色
customPot->xAxis->setTickLengthIn(3); // 轴线内刻度的长度
customPot->xAxis->setTickLengthOut(5); // 轴线外刻度的长度
customPot->xAxis->setUpperEnding(QCPLineEnding::esSpikeArrow);
//y
customPot->yAxis->setTicks(true);
customPot->yAxis->setBasePen(QPen(Qt::white, 1)); // 轴线的画笔
customPot->yAxis->setTickPen(QPen(Qt::white, 1)); // 轴刻度线的画笔
customPot->yAxis->setSubTickPen(QPen(Qt::white, 1)); // 轴子刻度线的画笔
customPot->yAxis->setTickLabelColor(Qt::white); // 轴刻度文字颜色
customPot->yAxis->setLabel(strY); // 只有设置了标签,轴标签的颜色才会显示
customPot->yAxis->setLabelColor(Qt::white); // 轴标签颜色
customPot->yAxis->setTickLengthIn(3); // 轴线内刻度的长度
customPot->yAxis->setTickLengthOut(5); // 轴线外刻度的长度
customPot->yAxis->setUpperEnding(QCPLineEnding::esSpikeArrow);
//设置x轴刻度个数
customPot->xAxis->ticker()->setTickCount(10);//10个主刻度
customPot->xAxis->ticker()->setTickStepStrategy(QCPAxisTicker::tssReadability);//可读性优于设置
// 每条网格对应一个刻度
customPot->xAxis->grid()->setPen(QPen(QColor(140, 140, 140), 1, Qt::DotLine)); // 网格线(对应刻度)画笔
customPot->yAxis->grid()->setPen(QPen(QColor(140, 140, 140), 1, Qt::DotLine));
customPot->xAxis->grid()->setSubGridPen(QPen(QColor(80, 80, 80), 1, Qt::DotLine)); // 子网格线(对应子刻度)画笔
customPot->yAxis->grid()->setSubGridPen(QPen(QColor(80, 80, 80), 1, Qt::DotLine));
customPot->xAxis->grid()->setSubGridVisible(true); // 显示子网格线
customPot->yAxis->grid()->setSubGridVisible(true);
customPot->xAxis->grid()->setZeroLinePen(Qt::NoPen);
customPot->yAxis->grid()->setZeroLinePen(Qt::NoPen);
//允许鼠标拖拽与滚轮缩放
customPot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
customPot->yAxis->setSubTicks(false);
}
第一个轮子,记录一下,可直接使用,方便以后重复利用
边栏推荐
- Bluebridge cup internet of things competition basic graphic tutorial - clock selection
- Five design details of linear regulator
- 实例009:暂停一秒输出
- QEMU demo makefile analysis
- On boost circuit
- Arduino+a4988 control stepper motor
- Example 007: copy data from one list to another list.
- go依赖注入--google开源库wire
- [NAS1](2021CVPR)AttentiveNAS: Improving Neural Architecture Search via Attentive Sampling (未完)
- Take you to understand the working principle of lithium battery protection board
猜你喜欢
Bluebridge cup internet of things competition basic graphic tutorial - clock selection
Management and use of DokuWiki
剑指 Offer 06. 从尾到头打印链表
List of linked lists
Array integration initialization (C language)
Sword finger offer 05 Replace spaces
Example 002: the bonus paid by the "individual income tax calculation" enterprise is based on the profit commission. When the profit (I) is less than or equal to 100000 yuan, the bonus can be increase
NTC thermistor application - temperature measurement
Tailq of linked list
【三层架构】
随机推荐
Management and use of DokuWiki (supplementary)
Some pitfalls of win10 network sharing
Shell script
Tailq of linked list
MHA High available Cluster for MySQL
More than 90% of hardware engineers will encounter problems when MOS tubes are burned out!
FIO测试硬盘性能参数和实例详细总结(附源码)
[NAS1](2021CVPR)AttentiveNAS: Improving Neural Architecture Search via Attentive Sampling (未完)
第十八章 使用工作队列管理器(一)
leetcode - 445. 两数相加 II
DCDC circuit - function of bootstrap capacitor
STM32 lights up the 1.8-inch screen under Arduino IDE
Imx6ull bare metal development learning 1-assembly lit LED
Sword finger offer 06 Print linked list from end to end
Speech recognition learning summary
Let's briefly talk about the chips commonly used in mobile phones - OVP chips
DokuWiki deployment notes
Sizeof (function name) =?
实例002:“个税计算” 企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可提成7.
Summary of SIM card circuit knowledge