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

Method eventFilter

examples/Lines/Advanced/mainwindow.cpp:66–81  ·  view source on GitHub ↗

Event filter for getting mouse position */

Source from the content-addressed store, hash-verified

64 Event filter for getting mouse position
65*/
66bool MainWindow::eventFilter(QObject *target, QEvent *event)
67{
68 if (target == m_chart) {
69 if (event->type() == QEvent::MouseMove) {
70 // When the mouse is over a data-point then fetch that data-point
71 // that belongs to the mouse-position and print the data value.
72 auto *mouseEvent = static_cast<QMouseEvent *>(event);
73 QPointF pos = mouseEvent->pos();
74 QModelIndex index = m_lines->indexAt(pos.toPoint());
75 if (index.isValid()) {
76 qDebug() << "Mouse position" << pos << "Data:" << m_model.data(index).toDouble();
77 }
78 }
79 }
80 return QWidget::eventFilter(target, event);
81}
82
83void MainWindow::on_lineTypeCB_currentIndexChanged(int index)
84{

Callers

nothing calls this directly

Calls 4

typeMethod · 0.45
indexAtMethod · 0.45
isValidMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected