PDA

View Full Version : Draw figure underneath other figure



Mnemonic
7th April 2010, 14:38
Hi, wrote the code and now i have problem. I would like next figures to be seen underneath the figures which have been already drawn. I wrote simple code below as example of the problem, line should be drawn underneath the rectangle:


Window::Window(QWidget *parent) :
QWidget(parent)
{
setMinimumSize(400,400);
setBackgroundRole(QPalette::Base);
setAutoFillBackground(true);
}

void Window::paintEvent(QPaintEvent *){
QPainter painter(this);
painter.setBrush(QBrush(Qt::yellow));
painter.drawRect(QRect(QPoint(100,100),QPoint(200, 200)));

painter.setCompositionMode(QPainter::CompositionMo de_SourceOver);

painter.setPen(QPen(Qt::red));
painter.drawLine(QPointF(150,50),QPointF(150,300)) ;
}