QGIS API Documentation 3.41.0-Master (af5edcb665c)
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#include "moc_qgstableview.cpp"
18
19#include <QWheelEvent>
20
22 : QTableView( parent )
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(), invertedPixelDelta, invertedAngleDelta, event->buttons(), event->modifiers() & ~Qt::ShiftModifier, event->phase(), event->inverted(), event->source() );
35 QTableView::wheelEvent( &axisSwappedScrollEvent );
36 }
37 else
38 {
39 QTableView::wheelEvent( event );
40 }
41}
QgsTableView(QWidget *parent=nullptr)
Constructor for QgsTableView.
void wheelEvent(QWheelEvent *event) override