summaryrefslogtreecommitdiffstats
path: root/examples/widgets/itemviews
diff options
context:
space:
mode:
authorChristoph Schleifenbaum <christoph@kdab.com>2011-12-22 19:33:28 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-22 17:56:55 +0200
commitae0fd6884d30ae2ce084e239468696aaec7f5795 (patch)
tree7342d45c8b2c9cbf309d2347812c4d83f1701ac3 /examples/widgets/itemviews
parent7df16fb4ccbe0476bc34274a77e98eec4e8d2d93 (diff)
QAbstractScrollArea - add SizeAdjustPolicy and viewportSizeHint
This patch adds SizeAdjustPolicy to QAbstractScrollArea. If it is set to AdjustToContents it will make use of the new protected viewportSizeHint() (BC since it was reserved in Qt5). This function returns a suggested size based on contents. Change-Id: I5d8aa517e88b8b21c5712e62b4d574c3aad99d3b Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'examples/widgets/itemviews')
-rw-r--r--examples/widgets/itemviews/spreadsheet/main.cpp3
-rw-r--r--examples/widgets/itemviews/spreadsheet/spreadsheet.cpp1
2 files changed, 3 insertions, 1 deletions
diff --git a/examples/widgets/itemviews/spreadsheet/main.cpp b/examples/widgets/itemviews/spreadsheet/main.cpp
index 1cc9205d7e..f518986bc5 100644
--- a/examples/widgets/itemviews/spreadsheet/main.cpp
+++ b/examples/widgets/itemviews/spreadsheet/main.cpp
@@ -42,14 +42,15 @@
#include "spreadsheet.h"
#include <QApplication>
+#include <QLayout>
int main(int argc, char** argv) {
Q_INIT_RESOURCE(spreadsheet);
QApplication app(argc, argv);
SpreadSheet sheet(10, 6);
sheet.setWindowIcon(QPixmap(":/images/interview.png"));
- sheet.resize(640, 420);
sheet.show();
+ sheet.layout()->setSizeConstraint(QLayout::SetFixedSize);
return app.exec();
}
diff --git a/examples/widgets/itemviews/spreadsheet/spreadsheet.cpp b/examples/widgets/itemviews/spreadsheet/spreadsheet.cpp
index 59d29f0e61..6fab0c2aae 100644
--- a/examples/widgets/itemviews/spreadsheet/spreadsheet.cpp
+++ b/examples/widgets/itemviews/spreadsheet/spreadsheet.cpp
@@ -64,6 +64,7 @@ SpreadSheet::SpreadSheet(int rows, int cols, QWidget *parent)
toolBar->addWidget(formulaInput);
table = new QTableWidget(rows, cols, this);
+ table->setSizeAdjustPolicy(QTableWidget::AdjustToContents);
for (int c = 0; c < cols; ++c) {
QString character(QChar('A' + c));
table->setHorizontalHeaderItem(c, new QTableWidgetItem(character));