#include <QMainWindow>
#include <QPainter>
#include <QScrollArea>
{
public:
{
painter.fillRect(geometry(), Qt::red);
}
};
{
Q_OBJECT
public:
{
setGeometry
(QRect(100,
100,
230,
230));
MyWidget* widget = new MyWidget;
widget
->setGeometry
(QRect(0,
0,
250,
250));
widget->setStyleSheet("border: 3px solid blue;");
area
->setGeometry
(QRect(0,
0,
200,
200));
area->setWidget(widget);
}
};
#include <QMainWindow>
#include <QPainter>
#include <QScrollArea>
class MyWidget : public QWidget
{
public:
virtual void paintEvent(QPaintEvent* e)
{
QPainter painter(this);
painter.fillRect(geometry(), Qt::red);
}
};
class ScrollTest : public QMainWindow
{
Q_OBJECT
public:
ScrollTest(QWidget *parent = 0) : QMainWindow(parent)
{
setGeometry(QRect(100,100,230,230));
MyWidget* widget = new MyWidget;
widget->setGeometry(QRect(0,0, 250, 250));
widget->setStyleSheet("border: 3px solid blue;");
QScrollArea* area = new QScrollArea(this);
area->setGeometry(QRect(0,0, 200, 200));
area->setWidget(widget);
}
};
To copy to clipboard, switch view to plain text mode
Bookmarks