QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
20 QgsTableView::QgsTableView( QWidget *parent )
21  : QTableView( parent )
22 {
23 
24 }
25 
26 void 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  QWheelEvent axisSwappedScrollEvent( event->posF(), event->globalPosF(),
34  invertedPixelDelta, invertedAngleDelta,
35  event->buttons(), event->modifiers() & ~Qt::ShiftModifier, event->phase(),
36  event->inverted(), event->source() );
37  QTableView::wheelEvent( &axisSwappedScrollEvent );
38  }
39  else
40  {
41  QTableView::wheelEvent( event );
42  }
43 }
QgsTableView::QgsTableView
QgsTableView(QWidget *parent=nullptr)
Constructor for QgsTableView.
Definition: qgstableview.cpp:20
QgsTableView::wheelEvent
void wheelEvent(QWheelEvent *event) override
Definition: qgstableview.cpp:26
qgstableview.h