Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <QtGui/QPainter>
- #include <QtWidgets/QApplication>
- #include <QtWidgets/QScrollArea>
- class Widget : public QWidget
- {
- Q_OBJECT
- public:
- explicit Widget(QWidget *parent = 0)
- : QWidget(parent)
- {
- resize(200, 200);
- }
- protected:
- void paintEvent(QPaintEvent *)
- {
- QPainter p(this);
- p.fillRect(-100, 100, 400, 400, Qt::blue);
- p.fillRect(rect(), Qt::red);
- }
- };
- int main(int argc, char *argv[])
- {
- QApplication app(argc, argv);
- QScrollArea scrollArea;
- scrollArea.setBackgroundRole(QPalette::Dark);
- scrollArea.setAlignment(Qt::AlignCenter);
- scrollArea.setWidgetResizable(false);
- scrollArea.setWidget(new Widget);
- scrollArea.resize(400, 400);
- scrollArea.show();
- return app.exec();
- }
- #include "main.moc"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement