QMainWin::QMainWin()
{
imgLabel
->setPixmap
(QPixmap::fromImage(*image
));
area
->setBackgroundRole
(QPalette::Dark);
area->setWidget(imgLabel);
setCentralWidget(area);
connect(action, SIGNAL(triggered()), this, SLOT(drawPixels()));
QMenu* menu
= menuBar
()->addMenu
(tr
("Drawing"));
menu->addAction(startAction);
x = y = 0;
}
void QMainWin::drawPixels()
{
for(int i = y; i < y+20; i++)
for(int j = x; j < x+20; j++)
image->setPixel(j, i, qRgb(255, 0, 0));
x += 20;
y += 20;
// This line is needed, else the picture doesn't get updated
imgLabel
->setPixmap
(QPixmap::fromImage(*image
));
imgLabel->update();
}