当前位置: 代码迷 >> QT开发 >> 请问图片里写字的有关问题
  详细解决方案

请问图片里写字的有关问题

热度:312   发布时间:2016-04-25 05:12:56.0
请教图片里写字的问题
比如一段代码:
C/C++ code
        QGraphicsScene *sceneImageRef = new QGraphicsScene;        vueRef->setScene(sceneImageRef);        QImage imageRef;        imageRef.load(fileNom2);        QPixmap pixmapRef = QPixmap::fromImage(imageRef.scaled(vueRef->size(), Qt::IgnoreAspectRatio));        sceneImageRef->addPixmap(pixmapRef);


就是在指定的框里显示一张名字为fileNom2的图片(可以zoomin,zoomout),然后我想在显示的这张图片上写字(显示字,比如"Qt, hello!"),怎么实现呢?
用QPainter类的drawText方法吗? 
谢谢!

------解决方案--------------------
然后怎么把这个QPixmap绘制到QWidget的QPainter上??
谢谢!

void paintEvent(QPaintEvent *event) {
QPainter painter(this);
painter.drawImage(....); // 在这里绘制你得到的pixmap
}
  相关解决方案