yes, here it is:
works: test.cpp
#include <QtGui>
#include "test.h"
Test::Test()
{
t2 = new Test2(this);
t->setWidget(t2);
vBoxLayout->addWidget(t);
setLayout(vBoxLayout);
}
int main(int argc, char **argv)
{
Test* t = new Test();
t->show();
return app.exec();
}
Test2::Test2()
{
s.setWidth(200);
s.setHeight(200);
//t = new QScrollArea();
//t->setWidget(this);
}
QSize Test2
::sizeHint() const {
return s;
}
#include <QtGui>
#include "test.h"
Test::Test()
{
vBoxLayout = new QVBoxLayout();
t2 = new Test2(this);
t = new QScrollArea();
t->setWidget(t2);
vBoxLayout->addWidget(t);
setLayout(vBoxLayout);
}
int main(int argc, char **argv)
{
QApplication app(argc, argv);
Test* t = new Test();
t->show();
return app.exec();
}
Test2::Test2()
{
s.setWidth(200);
s.setHeight(200);
//t = new QScrollArea();
//t->setWidget(this);
}
QSize Test2::sizeHint() const
{
return s;
}
To copy to clipboard, switch view to plain text mode
test.h:
#ifndef TEST_H
#define TEST_H
#include <QWidget>
#include <QVBoxLayout>
#include <QScrollArea>
{
public:
};
{
public:
Test();
private:
Test2* t2;
};
#endif // TEST_H
#ifndef TEST_H
#define TEST_H
#include <QWidget>
#include <QVBoxLayout>
#include <QScrollArea>
class Test2 : public QWidget
{
public:
Test2(QWidget* parent);
QScrollArea* t;
QSize sizeHint() const;
QSize s;
};
class Test : public QWidget
{
public:
Test();
private:
QVBoxLayout* vBoxLayout;
Test2* t2;
QScrollArea* t;
};
#endif // TEST_H
To copy to clipboard, switch view to plain text mode
Doesn't work:
#include <QtGui>
#include "test.h"
Test::Test()
{
t2 = new Test2(this);
//t = new QScrollArea();
//t->setWidget(t2);
vBoxLayout->addWidget(t2);
setLayout(vBoxLayout);
}
int main(int argc, char **argv)
{
Test* t = new Test();
t->show();
return app.exec();
}
{
s.setWidth(200);
s.setHeight(200);
t->setWidget(this);
}
QSize Test2
::sizeHint() const {
return s;
}
#include <QtGui>
#include "test.h"
Test::Test()
{
vBoxLayout = new QVBoxLayout();
t2 = new Test2(this);
//t = new QScrollArea();
//t->setWidget(t2);
vBoxLayout->addWidget(t2);
setLayout(vBoxLayout);
}
int main(int argc, char **argv)
{
QApplication app(argc, argv);
Test* t = new Test();
t->show();
return app.exec();
}
Test2::Test2(QWidget* parent) : QWidget(parent)
{
s.setWidth(200);
s.setHeight(200);
t = new QScrollArea();
t->setWidget(this);
}
QSize Test2::sizeHint() const
{
return s;
}
To copy to clipboard, switch view to plain text mode
test.h remains unmodified.
Bookmarks