{
Q_OBJECT
public:
resize(640, 480);
}
QRect r
(50,
50,
200,
100);
// for a bit of colour
linearGradient.setColorAt(0.0, Qt::white);
linearGradient.setColorAt(0.2, Qt::green);
linearGradient.setColorAt(1.0, Qt::black);
p.translate(320, 0); // put x origin in centre
p.setBrush(linearGradient);
p.drawRect(r);
p.setPen(Qt::red);
p.scale(-1.0, 1.0);
p.drawRect(r);
}
};
class Widget: public QWidget
{
Q_OBJECT
public:
Widget(QWidget *p = 0): QWidget(p) {
resize(640, 480);
}
void paintEvent(QPaintEvent *event) {
QRect r(50, 50, 200, 100);
// for a bit of colour
QLinearGradient linearGradient(r.topRight(), r.bottomLeft());
linearGradient.setColorAt(0.0, Qt::white);
linearGradient.setColorAt(0.2, Qt::green);
linearGradient.setColorAt(1.0, Qt::black);
QPainter p(this);
p.translate(320, 0); // put x origin in centre
p.setBrush(linearGradient);
p.drawRect(r);
p.setPen(Qt::red);
p.scale(-1.0, 1.0);
p.drawRect(r);
}
};
To copy to clipboard, switch view to plain text mode
Bookmarks