ペインティング フレームワークとして QPixmap で QPainter を使用しています。QGraphicsScene は QPixmap を保持しています。絵はうまくいきます。しかし、問題は QGraphicsView の背景色を変更すると画面に反映されないことです。QPixmap::fill(Qt::tranparent)で試しました。しかし、うまくいきませんでした。
この種の透明な QPixmap を実現するにはどうすればよいですか? 事前にサンクス?
int main(int argc, char **argv){
QApplication a(argc, argv);
QMainWindow *win = new QMainWindow();
win->resize(600,600);
win->move(80,80);
win->show();
QGraphicsScene *scene = new QGraphicsScene(win);
QGraphicsView view(scene,win);
view.resize(590,590);
view.setBackgroundBrush(QColor(rand()%255,rand()%255, rand()%255, 255));
view.show();
QPixmap *pix = new QPixmap(600,600);
pix->fill(&view,QPoint(0,0));
QGraphicsPixmapItem *item = scene->addPixmap(*pix);
QPainter *painter = new QPainter(pix);
int count=10;
while(count){
painter->setPen((*new QColor(rand()%255,rand()%255, rand()%255, 255)));
painter->setBrush(QColor(rand()%255,rand()%255, rand()%255, 255));
painter->drawRect(rand()%300, rand()%300, rand()%300, rand()%300);
item->setPixmap(*pix);
a.processEvents(0x00);
count--;
}
return a.exec();
}