Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <QtWidgets>
- class Widget : public QWidget
- {
- Q_OBJECT
- public:
- explicit Widget(QWidget *parent = 0)
- : QWidget(parent)
- {
- resize(60, 60);
- }
- protected:
- void paintEvent(QPaintEvent *e) {
- QPainter p(this);
- p.fillRect(rect(), Qt::red);
- QPainterPath fill;
- fill.addRect(rect());
- QPainterPath excluded;
- excluded.addRect(20, 20, 20, 20);
- p.setClipPath(fill.subtracted(excluded));
- p.fillRect(10, 10, 40, 40, Qt::blue);
- }
- };
- int main(int argc, char **argv)
- {
- QApplication app(argc, argv);
- Widget widget;
- widget.show();
- return app.exec();
- }
- #include "main.moc"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement