我是QT新手。我复制了光栅窗口示例,然后将其重写为普通程序而不是类程序。下面是代码
#include <QtGui>
int main(int argc, char *argv[]){
QGuiApplication app(argc, argv);
QWindow w;
w.showMaximized();
QBackingStore *m = new QBackingStore(&w);
m->resize(w.size());
QRect rect(0, 0, w.width()/2, w.height()/2);
m->beginPaint(rect);
QPaintDevice *device = m->paintDevice();
QPainter painter(device);
painter.fillRect(0, 0, w.width(), w.height(), QGradient::NightFade);
painter.end();
m->endPaint();
m->flush(rect);
QRect rect1(w.width()/2, w.height()/2, w.width()/2, w.height()/2);
m->flush(rect1);
return app.exec();
}
在以上程序中,我期望fillRec
仅填充“ rect”。但是它也填充了“ rect1”。为什么会这样?