class MainWindow : public QMainWindow
{
    Q_OBJECT
    
public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();

protected:
    QImage obraz;

    void paintEvent(QPaintEvent*);
    void mouseMoveEvent(QMouseEvent* event);
    void mousePressEvent(QMouseEvent* event);
};

// ...

void
MainWindow::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    painter.drawImage(0, 0, tymczasowy);
}


void
MainWindow::mouseMoveEvent(QMouseEvent* event)
{

// rysowanie na tablicy

    repaint();
}

Add a code snippet to your website: www.paste.org