MCPcopy Create free account
hub / github.com/KDAB/KDChart / MainWindow

Method MainWindow

examples/Lines/Advanced/mainwindow.cpp:24–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22using namespace KDChart;
23
24MainWindow::MainWindow(QWidget *parent)
25 : QWidget(parent)
26{
27 setupUi(this);
28
29 m_curColumn = -1;
30 m_curOpacity = 0;
31
32 auto *chartLayout = new QHBoxLayout(chartFrame);
33 m_chart = new Chart();
34 chartLayout->addWidget(m_chart);
35
36 m_model.loadFromCSV(":/data");
37
38 // Set up the diagram
39 m_lines = new LineDiagram(this);
40 m_lines->setModel(&m_model);
41
42 auto *xAxis = new CartesianAxis(m_lines);
43 auto *yAxis = new CartesianAxis(m_lines);
44 xAxis->setPosition(KDChart::CartesianAxis::Bottom);
45 yAxis->setPosition(KDChart::CartesianAxis::Left);
46 m_lines->addAxis(xAxis);
47 m_lines->addAxis(yAxis);
48
49 m_chart->coordinatePlane()->replaceDiagram(m_lines);
50 m_chart->setGlobalLeading(20, 20, 20, 20);
51 // Instantiate the timer
52 auto *timer = new QTimer(this);
53 connect(timer, SIGNAL(timeout()), this, SLOT(slot_timerFired()));
54 timer->start(30);
55
56 // Change the cursor to IBeamCursor inside Chart widget.
57 m_chart->setCursor(Qt::IBeamCursor);
58
59 // Install event filter on Chart to get the mouse position
60 m_chart->installEventFilter(this);
61}
62
63/**
64 Event filter for getting mouse position

Callers

nothing calls this directly

Calls 8

loadFromCSVMethod · 0.80
setModelMethod · 0.45
setPositionMethod · 0.45
addAxisMethod · 0.45
replaceDiagramMethod · 0.45
coordinatePlaneMethod · 0.45
setGlobalLeadingMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected