当前位置:网站首页>轮子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);
}
第一个轮子,记录一下,可直接使用,方便以后重复利用
边栏推荐
- Explain task scheduling based on Cortex-M3 in detail (Part 1)
- Xrosstools tool installation for X-Series
- Arduino burning program and Arduino burning bootloader
- Tailq of linked list
- [nas1] (2021cvpr) attentivenas: improving neural architecture search via attentive sampling (unfinished)
- 实例004:这天第几天 输入某年某月某日,判断这一天是这一年的第几天?
- Go dependency injection -- Google open source library wire
- STM32 outputs 1PPS with adjustable phase
- [noi simulation] juice tree (tree DP)
- 287. 寻找重复数-快慢指针
猜你喜欢
![[paper reading] the latest transfer ability in deep learning: a survey in 2022](/img/6b/b564fb7a6895329073fb5eaff64340.png)
[paper reading] the latest transfer ability in deep learning: a survey in 2022

Brief discussion on Buck buck circuit

Example 010: time to show

STM32 virtualization environment of QEMU

STM32 single chip microcomputer -- debug in keil5 cannot enter the main function

每日一题——替换空格
![[three tier architecture]](/img/73/c4c75a453f03830e83cabb0762eb9b.png)
[three tier architecture]

Classic application of MOS transistor circuit design (2) - switch circuit design

【NOI模拟赛】汁树(树形DP)
实例001:数字组合 有四个数字:1、2、3、4,能组成多少个互不相同且无重复数字的三位数?各是多少?
随机推荐
剑指 Offer 09. 用两个栈实现队列
Imx6ull bare metal development learning 1-assembly lit LED
OC and OD gate circuit
实例006:斐波那契数列
Bluebridge cup internet of things competition basic graphic tutorial - clock selection
FIO测试硬盘性能参数和实例详细总结(附源码)
[three tier architecture and JDBC summary]
UE pixel stream, come to a "diet pill"!
Classic application of MOS transistor circuit design (1) -iic bidirectional level shift
Lori remote control commissioning record
[noi simulation] juice tree (tree DP)
Stm32--- systick timer
Apaas platform of TOP10 abroad
实例005:三数排序 输入三个整数x,y,z,请把这三个数由小到大输出。
Let's briefly talk about the chips commonly used in mobile phones - OVP chips
Negative pressure generation of buck-boost circuit
L298N module use
Synchronization of QT multithreading
Low code platform | apaas platform construction analysis
Xrosstools tool installation for X-Series