#include #include #include int main( int argc, char *argv[] ) { QApplication app( argc, argv ); QTableWidget table; // Größe festlegen table.setRowCount( 5 ); table.setColumnCount( 5 ); // Balken verstecken table.horizontalHeader()->setVisible( false ); table.verticalHeader()->setVisible( false ); // Die Größe der Zellen in der Tabelle hängt vom Inhalt ab table.resizeRowsToContents(); table.resizeColumnsToContents(); // Die Tabelle soll vollständig angezeigt 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.frameWidth() * 2, table.verticalHeader()->length() + table.frameWidth() * 2 ); // Titel setzen und Widget anzeigen table.setWindowTitle( "TableWidget" ); table.show(); return app.exec(); }