Not quite sure what you're looking for. Maybe this example will help you out. Here the scroll area is set to the dialog, but you could easily enough set it to a QFrame or any other QWidget.
#ifndef SCROLLTEST_H
#define SCROLLTEST_H
#include <QtGui>
{
Q_OBJECT
public:
virtual ~ScrollTest();
};
#endif // SCROLLTEST_H
#include "scrolltest.h"
{
for(int i = 0; i < 25; i++)
{
scroll_layout->addWidget(button);
}
scroll_widget->setLayout(scroll_layout);
scroll_area->setWidget(scroll_widget);
main_layout->addWidget(scroll_area);
setLayout(main_layout);
}
ScrollTest::~ScrollTest()
{}
#include <QApplication>
#include "scrolltest.h"
int main(int argc, char *argv[])
{
ScrollTest st;
st.show();
return a.exec();
}
#ifndef SCROLLTEST_H
#define SCROLLTEST_H
#include <QtGui>
class ScrollTest : public QDialog
{
Q_OBJECT
public:
ScrollTest(QWidget * parent = 0);
virtual ~ScrollTest();
};
#endif // SCROLLTEST_H
#include "scrolltest.h"
ScrollTest::ScrollTest(QWidget * parent) : QDialog(parent)
{
QWidget * scroll_widget = new QWidget();
QVBoxLayout * scroll_layout = new QVBoxLayout();
for(int i = 0; i < 25; i++)
{
QPushButton * button = new QPushButton("ScrollTest");
scroll_layout->addWidget(button);
}
scroll_widget->setLayout(scroll_layout);
QScrollArea * scroll_area = new QScrollArea();
scroll_area->setWidget(scroll_widget);
QVBoxLayout * main_layout = new QVBoxLayout();
main_layout->addWidget(scroll_area);
setLayout(main_layout);
}
ScrollTest::~ScrollTest()
{}
#include <QApplication>
#include "scrolltest.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
ScrollTest st;
st.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks