I am trying to create a class derived from QScrollArea, so I can promote ScrollArea to my custom class in form editor. I have this code:
#include <QWidget>
#include <QVBoxLayout>
#include <QPushButton>
#include "CustomScrollArea.h"
CustomScrollArea::CustomScrollArea(QWidget *parent) :
QScrollArea (parent)
{
setWidgetResizable( true );
QWidget *widget = new QWidget();
QVBoxLayout *layout = new QVBoxLayout();
widget->setLayout( layout );
setWidget( widget );
for (int i = 0; i < 10; i++)
{
QPushButton *button = new QPushButton( QString( "%1" ).arg( i ) );
layout->addWidget( button );
}
}
the problem I have is that buttons are not displayed that way...
the .ui contents:
...
<widget class="QWidget" name="centralWidget">
<widget class="CustomScrollArea" name="scrollArea">
<property name="geometry">
<rect>
<x>40</x>
<y>40</y>
<width>221</width>
<height>201</height>
</rect>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>219</width>
<height>199</height>
...
