2012-12-20 27 views

回答

0

你只得到你想要捕捉的,那麼你結合的邊界矩形使其到QPixmap。您可以在此時保存QPixmap

未經檢驗的,而應該是沿着線...

import operator 

items = get_target_items() # just get all the items you want 
# combine all the scene rects for the items 
# equiv: totalRect = rect1 | rect2 | ... 
totalRect = reduce(operator.or_, (i.sceneBoundingRect() for i in items)) 

pix = QtGui.QPixmap(totalRect.width(), totalRect.height()) 
painter = QtGui.QPainter(pix) 
scene.render(painter, totalRect) 
pix.save("capture.jpg", "JPG")