Make QMainWindow scrollable
-
hello everybody.
I can't add scrollbar to my widget. I've tried everything, here is the latest version:
@
#include "mainwindow.h"MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
setFixedSize(640,640);addOrderButton = new QPushButton(QString::fromLocal8Bit("Добавить заказ"),this); connect(addOrderButton, SIGNAL(clicked()),this, SLOT(addOrder())); orders = new QVector<QWidget*>(); layout = new QVBoxLayout; scrollArea = new QScrollArea; setCentralWidget(scrollArea); addOrder(); layout->addWidget(addOrderButton); scrollArea->setLayout(layout);
}
MainWindow::~MainWindow()
{}
void MainWindow::addOrder()
{
orderWidget* w = new orderWidget(this);
orders->append(w);
layout->insertWidget(orders->count() - 1, w);
}
@Sorry for the stupid question but i really stuck with it. What am i doing wrong?
-
@layout->insertWidget(orders->count() - 1, w);@
here:
@orders->count() - 1 == -1@You should
@layout->addWidget(addOrderButton);
orders->append(addOrderButton);@