How to create a QTable widget which has 2 columnes, and in first column there is a QComboBox and in the second column there is a QSpinBox so that the combo box gets all the space of table and only a very small place leaves for QSpinBox (for 2-3 digits).
+1
A:
First, use setCellWidget() to set the QComboBox and QSpinBox as the widgets to be displayed in the appropriate cell.
Second, use horizontalHeader() to access the QHeaderView for the QTableView, then set the ResizeMode accordingly.
QTableWidget* table = new QTableWidget( this );
table->setColumnCount( 2 );
table->setRowCount( 1 );
table->setCellWidget ( 0, 0, new QComboBox( table ) );
table->setCellWidget ( 0, 1, new QSpinBox( table ) );
table->horizontalHeader()->setResizeMode( 0, QHeaderView::Stretch );
table->horizontalHeader()->setResizeMode( 1, QHeaderView::ResizeToContents );
Casey
2010-07-03 19:31:18
QSpinBox is smaller then befor but it is still very big. I can write there about 11 digits, but I need only 2 or 3
Narek
2010-07-04 04:54:32
Actually everything is OK indeed. It is big because its caption(the note in the table header) is big.
Narek
2010-07-04 15:45:03