QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
qgstableview.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgstableview.cpp
3 ---------------
4 begin : March 2022
5 copyright : (C) 2022 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#include "qgstableview.h"
17
18#include <QWheelEvent>
19
21 : QTableView( parent )
22{
23
24}
25
26void QgsTableView::wheelEvent( QWheelEvent *event )
27{
28 if ( event->modifiers() & Qt::ShiftModifier )
29 {
30 // a wheel event with the shift modifier switches a vertical scroll to a horizontal scroll (or vice versa)
31 const QPoint invertedPixelDelta = QPoint( event->pixelDelta().y(), event->pixelDelta().x() );
32 const QPoint invertedAngleDelta = QPoint( event->angleDelta().y(), event->angleDelta().x() );
33
34 QWheelEvent axisSwappedScrollEvent( event->position(), event->position(),
35 invertedPixelDelta, invertedAngleDelta,
36 event->buttons(), event->modifiers() & ~Qt::ShiftModifier, event->phase(),
37 event->inverted(), event->source() );
38 QTableView::wheelEvent( &axisSwappedScrollEvent );
39 }
40 else
41 {
42 QTableView::wheelEvent( event );
43 }
44}
QgsTableView(QWidget *parent=nullptr)
Constructor for QgsTableView.
void wheelEvent(QWheelEvent *event) override