简体   繁体   English

如何从QChart显式设置刻度标签?

[英]How do I set tick label explicitly from QChart?

I have to create a chart and use QChart . 我必须创建一个图表并使用QChart So I looked at the QChart dynamic spline example (because I'm going to create a dynamic chart), and I found something strange there. 因此,我看了看QChart动态样条线示例(因为我将创建一个动态图表),并且在那里发现了一些奇怪的东西。

Below is the launch screen. 下面是启动屏幕。 The code is the example code provided by Qt, except for setTickCount() . 该代码是Qt提供的示例代码,但setTickCount()除外。

launch screen image: 启动屏幕图像: 启动屏幕图像

dynamic spline chart example code from Qt home page Qt主页上的动态样条图示例代码

I changed the value of tick from 5 to 10. I thought that if I changed it to 10, it would appear as 0, 1, 2, 3, 4, ..., 10 as the scale value. 我将tick的值从5更改为10。我认为,如果将其更改为10,则刻度值将显示为0、1、2、3、4,...,10。 But it does not. 但事实并非如此。

When moving by the scale interval, I think that it should be increased only by the scale interval exactly. 在按比例尺间隔移动时,我认为应该仅按比例尺间隔精确地增加它。 What should I do? 我该怎么办? The code looks fine. 代码看起来不错。

You might want to try calling void QValueAxis::applyNiceNumbers() , somewhere in the constructor. 您可能想尝试在构造函数中的某个位置调用void QValueAxis::applyNiceNumbers() Take a look at void QValueAxis::applyNiceNumbers() in Qt documentation. 看一下Qt文档中的void QValueAxis :: applyNiceNumbers()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM