是应用了他的render函数,render的作用是:
代码如下:
有两个注意事项:
- 如果你把QImage image(130 * mSceneSize.width()/ mSceneSize.height(),130 ,QImage::Format_ARGB32); 写成QImage image。无论如何image都是无法save成功的。因为image没有初始化。
- 如果你的scene里有的item/widget的坐标位于目前可显示的外面,意思是你的scene现在大小是100*100,但是有一个item的坐标位于100*101,那么调用scene->render时会有ASSERT错误:
你当然可以忽略掉他,在release模式下是没有此类问题的。---------------------------Microsoft Visual C++ Debug Library---------------------------Debug Error!
Program: ...\Win32\Debug\Maker.exeModule: 5.0.1File: global\qglobal.cppLine: 1951
ASSERT: "!item->d_ptr->itemDiscovered" in file graphicsview\qgraphicsscenebsptreeindex.cpp, line 343
(Press Retry to debug the application)---------------------------Abort Retry Ignore---------------------------
当然了你用QGraphicsView的render方法也可以获得view的缩略图。
http://blog.csdn.net/LCL_data/article/details/8731892