#include #include #include int main( int argc, char *argv[] ) { QApplication app( argc, argv ); QTableWidget table; // Größe festlegen table.setRowCount( 5 ); table.setColumnCount( 5 ); // Die Größe der Zellen in der Tabelle hängt vom Inhalt ab table.resizeRowsToContents(); table.resizeColumnsToContents(); // Die Tabelle soll vollständig dargestellt werden, ohne eine // Scrollbar anzuzeigen. // https://stackoverflow.com/a/37615363 // https://stackoverflow.com/a/40300974 table.setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); table.setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); table.setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); table.setFixedSize( table.horizontalHeader()->length() + table.verticalHeader()->width() + table.frameWidth() * 2, table.verticalHeader()->length() + table.horizontalHeader()->height() + table.frameWidth() * 2 ); // Titel setzen und Widget anzeigen table.setWindowTitle( "TableWidget" ); table.show(); return app.exec(); }