-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustomtable.h
48 lines (38 loc) · 1.28 KB
/
customtable.h
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
39
40
41
42
43
44
45
46
47
48
#ifndef CUSTOMTABLE_H
#define CUSTOMTABLE_H
#include <QTableWidget>
#include <QKeyEvent>
#include <QModelIndex>
//#include "regcashmain.h"
class customTable:public QTableWidget
{
Q_OBJECT
private:
float prezzo;
public:
customTable(QWidget* parent=0):QTableWidget(parent){}
protected:
void keyPressEvent(QKeyEvent *e)
{
if(e->key()==Qt::Key_Backspace)
{
//qInfo("hai premuto backspace");
//QTableWidget.SelectRows();
//QTableWidget::removeRow(QTableWidget::SelectedClicked);
//float prezzo = QTableWidget.model()->data(QTableWidget.model()->index(0,4)).toFloat();
if (QTableWidget::rowCount()>0){
QModelIndexList indexes = QTableWidget::selectionModel()->selection().indexes();
QModelIndex index = indexes.at(0);
prezzo=this->item(index.row(),4)->text().toFloat();
//qint16 riga=;
QTableWidget::removeRow(index.row());
emit backSpacePressed();
}
//connect(QTableWidget,SIGNAL(backSpacePressed(float)),this,SLOT(test()));
}
else { QTableWidget::keyPressEvent(e); }
}
signals:
void backSpacePressed();
};
#endif // CUSTOMTABLE_H