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:
Qt Code:
  1. Window::Window(QWidget *parent) :
  2. QWidget(parent)
  3. {
  4. setMinimumSize(400,400);
  5. setBackgroundRole(QPalette::Base);
  6. setAutoFillBackground(true);
  7. }
  8.  
  9. void Window::paintEvent(QPaintEvent *){
  10. QPainter painter(this);
  11. painter.setBrush(QBrush(Qt::yellow));
  12. painter.drawRect(QRect(QPoint(100,100),QPoint(200,200)));
  13.  
  14. painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
  15.  
  16. painter.setPen(QPen(Qt::red));
  17. painter.drawLine(QPointF(150,50),QPointF(150,300));
  18. }
To copy to clipboard, switch view to plain text mode