PDA

View Full Version : Problem with QScrollArea layout and alignment



qtmude
20th March 2013, 12:51
http://i.imgur.com/KtWYCIJ.jpg

As you can see I have a QScrollArea with several groupBoxes in it. Those groupboxes may or may not appear at a given time.

What do I need:
-QscrollArea fit the parent tab widget page.
-QscrollArea has a scroll bar when needed.
-All the groupboxes are piled on the top.


Whod do I have:

ScrollArea:
-vertical layout
-vertical policy maximum (or expanding)
-aligment top

GroupBoxes:
-fixed max height
-align top


can you help me please?

Santosh Reddy
21st March 2013, 10:39
How are you setting the QScrollArea on to the tab widget?

qtmude
21st March 2013, 15:14
I'm using qt designer


tabWidget = new QTabWidget(splitter);
tabWidget->setObjectName(QString::fromUtf8("tabWidget"));
QSizePolicy sizePolicy2(QSizePolicy::Preferred, QSizePolicy::Expanding);
sizePolicy2.setHorizontalStretch(0);
sizePolicy2.setVerticalStretch(0);
sizePolicy2.setHeightForWidth(tabWidget->sizePolicy().hasHeightForWidth());
tabWidget->setSizePolicy(sizePolicy2);
tabWidget->setMaximumSize(QSize(300, 16777215));
General = new QWidget();
General->setObjectName(QString::fromUtf8("General"));
scrollArea = new QScrollArea(General);
scrollArea->setObjectName(QString::fromUtf8("scrollArea"));
scrollArea->setGeometry(QRect(9, 9, 276, 635));
QSizePolicy sizePolicy3(QSizePolicy::Fixed, QSizePolicy::Maximum);
sizePolicy3.setHorizontalStretch(0);
sizePolicy3.setVerticalStretch(0);
sizePolicy3.setHeightForWidth(scrollArea->sizePolicy().hasHeightForWidth());
scrollArea->setSizePolicy(sizePolicy3);
scrollArea->setMinimumSize(QSize(0, 0));
scrollArea->setWidgetResizable(true);
scrollArea->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::Al ignTop);
scrollAreaWidgetContents = new QWidget();
scrollAreaWidgetContents->setObjectName(QString::fromUtf8("scrollAreaWidgetContents"));
scrollAreaWidgetContents->setGeometry(QRect(0, 0, 257, 963));
verticalLayout_4 = new QVBoxLayout(scrollAreaWidgetContents);
verticalLayout_4->setSpacing(6);
verticalLayout_4->setContentsMargins(6, 6, 6, 6);
verticalLayout_4->setObjectName(QString::fromUtf8("verticalLayout_4"));
Namebox = new QGroupBox(scrollAreaWidgetContents);
Namebox->setObjectName(QString::fromUtf8("Namebox"));
QSizePolicy sizePolicy4(QSizePolicy::Preferred, QSizePolicy::Maximum);
sizePolicy4.setHorizontalStretch(0);
sizePolicy4.setVerticalStretch(0);
sizePolicy4.setHeightForWidth(Namebox->sizePolicy().hasHeightForWidth());
Namebox->setSizePolicy(sizePolicy4);
Namebox->setMaximumSize(QSize(16777215, 53));
Namebox->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::Al ignTop);
horizontalLayout_6 = new QHBoxLayout(Namebox);
horizontalLayout_6->setSpacing(6);
horizontalLayout_6->setContentsMargins(6, 6, 6, 6);
horizontalLayout_6->setObjectName(QString::fromUtf8("horizontalLayout_6"));


if you prefer you can download the ui file here (https://dl.dropbox.com/u/5545845/scrollareabug.ui)

thanks!

Lesiok
21st March 2013, 16:08
Do not use restrictions on the size of the frames. See how it looks awful on another computer.
8830. Second at the end (as last widget on scroll area) put vertical spacer.