Adjust QTableWidget to contents & How to set a precise size of QTableWidget to prevent from having scroll bars?
I wish to set a precise size which does not leave extra space in the viewport,
and on the other hand, not having scroll bars show up. What is the
precise size?
I wrote an example to demonstrate, Please pay attention to the lines:
this->setVisible(true);
this->setVisible(false);
autoADCalibrationTableWidget->resizeColumnsToContents(); auotoADCalibrationTableWidget->resizeRowsToContents(); int newWidth = 0; int newHeight =0; for (int i = 0; i < autoADCalibrationTableWidget->columnCount(); i++) { newWidth+= autoADCalibrationTableWidget->columnWidth(i); } for (int j = 0; j < autoADCalibrationTableWidget->rowCount(); j++) { newHeight+= autoADCalibrationTableWidget->rowHeight(j); }
this->setVisible(true); this->setVisible(false);
newWidth+=autoADCalibrationTableWidget->verticalHeader()->width() + 2 * autoADCalibrationTableWidget->frameWidth(); newHeight+=autoADCalibrationTableWidget->horizontalHeader()->height() + 2 * autoADCalibrationTableWidget->frameWidth();
autoADCalibrationTableWidget->setMaximumWidth(newWidth); autoADCalibrationTableWidget->setMinimumWidth(newWidth);
autoADCalibrationTableWidget->setMaximumHeight(newHeight); autoADCalibrationTableWidget->setMinimumHeight(newHeight);
|
阅读(2586) | 评论(0) | 转发(0) |