当前位置:网站首页>Qchart note 2: add rollover display
Qchart note 2: add rollover display
2022-06-27 04:08:00 【gdizcm】
Pick up note 1. After the line is displayed , I want to hover over the line , Displays the... Of the point Y The value of the shaft . Like the following figure .

The implementation is like this . Inherit first QChartView class , Add a slot function to the class , Used to connect LineSeries Hover signal on .
QObject::connect(series, SIGNAL(hovered(const QPointF&,bool)), chartView, SLOT(showPos(const QPointF&, bool)));
class ChartView : public QChartView
{
Q_OBJECT
public:
ChartView(QChart *chart, QWidget *parent = 0);
public slots:
void showPos(const QPointF&, bool);
};
void ChartView::showPos(const QPointF& point, bool state)
{
QPoint tempPoint;
tempPoint.setX(qRound(point.x()));
tempPoint.setY(qRound(point.y()));
if (state && static_cast<QSplineSeries*>(this->chart()->series().at(0))->points().contains(tempPoint)) {
QToolTip::showText(QCursor::pos(), QString("%1").arg(tempPoint.y()), this);
}
}In this slot function , The integer part of the first value , Because the point is the value of an integer , Then judge whether the point is LineSeries On , If you're here , Displayed at the mouse position .
Allied , With a little modification, you can also display x The value of the shaft .
边栏推荐
- 手机新领域用法知识
- 缓存综合项目--秒杀架构
- 2022-06-26:以下golang代码输出什么?A:true;B:false;C:编译错误。 package main import “fmt“ func main() { type
- 实践 DevOps 时,可能面临的六大挑战
- Six possible challenges when practicing Devops
- promise源码-class版本【三、Promise源码】【代码详细注释/测试案例完整】
- Mysql database foundation: DQL data query language
- Pat class a 1024 palindromic number
- 2021:Beyond Question-Based Biases:Assessing Multimodal Shortcut Learning in Visual Question Answeri
- Quickly master asp Net authentication framework identity - reset password by mail
猜你喜欢

基于MobileNet-Yolov4搭建轻量化目标检测

Network structure and model principle of convolutional neural network (CNN)

MySQL development environment

Pat grade a 1026 table tennis

Ledrui ldr6035 usb-c interface device supports rechargeable OTG data transmission scheme.

Cultural tourism light show breaks the time and space constraints and shows the charm of night tour in the scenic spot

MySql的开发环境

Ldr6028 OTG data transmission scheme for mobile devices while charging

Career outlook, money outlook and happiness outlook

Kotlin Compose 自定义 CompositionLocalProvider CompositionLocal
随机推荐
How to make ef core 6 support dateonly type
jmeter分布式压测
2020:MUTANT: A Training Paradigm for Out-of-Distribution Generalizationin Visual Question Answering
fplan-布局
promise源码-class版本【三、Promise源码】【代码详细注释/测试案例完整】
Kotlin Compose compositionLocalOf 与 staticCompositionLocalOf
JMeter takes the result of the previous request as the parameter of the next request
Interview-01
基于MobileNet-Yolov4搭建轻量化目标检测
Pat grade a 1018 public bike management
Pat grade a 1025 pat ranking
Why does C throw exceptions when accessing null fields?
电商产品如何在知乎上进行推广和打广告?
I found a JSON visualization tool artifact. I love it!
fplan-Powerplan实例
Implementation of window encryption shell
Career outlook, money outlook and happiness outlook
JMeter distributed pressure measurement
2020:MUTANT: A Training Paradigm for Out-of-Distribution Generalizationin Visual Question Answering
2022-06-26:以下golang代码输出什么?A:true;B:false;C:编译错误。 package main import “fmt“ func main() { type