0

This code correctly displays an image, and resizes it when the window is resized:

QLabel *imageLabel;
QTabWidget *imageTabWidget;
// new...
imageTabWidget->addTab(imageLabel, "Image");

I would like the same behaviour putting the image in a table (still inside the previous tab). However all I can get now is a fixed size image:

QTableWidget *innerTable = new QTableWidget;
innerTable->setRowCount(1);
innerTable->setColumnCount(1);
innerTable->setCellWidget(0, 0, imageLabel);
innerTable->resizeColumnsToContents();
innerTable->resizeRowsToContents();
imageTabWidget->addTab(innerTable, "Image");

Is it possible to have a resizeable table at all?
Thank you.

Pietro
  • 12,086
  • 26
  • 100
  • 193

1 Answers1

1

You need to use layouts to get things to re-size how you'd like, see:

http://doc.qt.digia.com/qt/layout.html

Using the designer makes creating layouts much easier. (Create a widget in the designer then create an instance of it in code, then add to the tab widget).

paulm
  • 5,629
  • 7
  • 47
  • 70