Advertisement
tasuku

main.cpp

Nov 15th, 2012
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <QtGui/QPainter>
  2. #include <QtWidgets/QApplication>
  3. #include <QtWidgets/QScrollArea>
  4.  
  5. class Widget : public QWidget
  6. {
  7.     Q_OBJECT
  8.  
  9. public:
  10.     explicit Widget(QWidget *parent = 0)
  11.         : QWidget(parent)
  12.     {
  13.         resize(200, 200);
  14.     }
  15.  
  16. protected:
  17.     void paintEvent(QPaintEvent *)
  18.     {
  19.         QPainter p(this);
  20.         p.fillRect(-100, 100, 400, 400, Qt::blue);
  21.         p.fillRect(rect(), Qt::red);
  22.     }
  23. };
  24.  
  25. int main(int argc, char *argv[])
  26. {
  27.     QApplication app(argc, argv);
  28.  
  29.     QScrollArea scrollArea;
  30.     scrollArea.setBackgroundRole(QPalette::Dark);
  31.     scrollArea.setAlignment(Qt::AlignCenter);
  32.     scrollArea.setWidgetResizable(false);
  33.     scrollArea.setWidget(new Widget);
  34.     scrollArea.resize(400, 400);
  35.     scrollArea.show();
  36.    
  37.     return app.exec();
  38. }
  39.  
  40. #include "main.moc"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement