QTableWidget with different types
Solved
General and Desktop
-
Well, you can set any widget into Cell, for example:
QLineEdit for strings and QSpinBox for digits.
@QTableWidget::setCellWidget ( int row, int column, QWidget * widget )@ -
That's a good idea. Thanks.
However, I've just tested it and there's a problem :
My QTableWidget is composed by about a thousand cells. So when I apply the method that create QLineEdit or QSpinBox, it takes about 5 seconds to display while when I was using only QTableWidgetItem it was immediate.So, If someone know a way to specify the type of a QTableWidgetItem, it would be much better.
-
I used this solution where you have a QLineEdit in each cell.
for(int trow=0; trow <= 2; trow++ ) { for(int tcolumn=0; tcolumn <= 3; tcolumn++ ) { QLineEdit * tableline = new QLineEdit; tableline->setValidator( new QDoubleValidator(0, 100, 2, this) ); ui->tableWidget->setCellWidget ( trow, tcolumn, tableline); } }