我是 Qt/Embedded 的新手。我想用来QPainter
在 a 上画东西QPixmap
,这将被添加到QGraphicsScene
. 这是我的代码。但它没有在像素图上显示图纸。它仅显示黑色像素图。
int main(int argc, char **argv) {
QApplication a(argc, argv);
QMainWindow *win1 = new QMainWindow();
win1->resize(500,500);
win1->show();
QGraphicsScene *scene = new QGraphicsScene(win1);
QGraphicsView view(scene, win1);
view.show();
view.resize(500,500);
QPixmap *pix = new QPixmap(500,500);
scene->addPixmap(*pix);
QPainter *paint = new QPainter(pix);
paint->setPen(*(new QColor(255,34,255,255)));
paint->drawRect(15,15,100,100);
return a.exec();
}