-
-
Notifications
You must be signed in to change notification settings - Fork 557
/
Copy pathtablewidget.cpp
38 lines (33 loc) · 964 Bytes
/
tablewidget.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// This file is a part of "grblControl" application.
// Copyright 2015 Hayrullin Denis Ravilevich
#include "tablewidget.h"
#include <QEvent>
#include <QKeyEvent>
#include <QDebug>
TableWidget::TableWidget(QWidget *parent) :
QTableWidget(parent)
{
}
void TableWidget::keyPressEvent(QKeyEvent *event)
{
// qDebug() << "keyPressEvent: " << event->key();
if (this->state() != this->EditingState) {
switch (event->key())
{
case Qt::Key_Return:
this->editItem(this->currentItem());
break;
case Qt::Key_Tab:
if (this->currentRow() < (this->rowCount() - 1)) {
this->setCurrentCell(this->currentRow() + 1, 0);
}
return;
case Qt::Key_Backtab:
if (this->currentRow() > 0) {
this->setCurrentCell(this->currentRow() - 1, 0);
}
return;
}
}
QTableWidget::keyPressEvent(event);
}