Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例如,我有一个包含一些 QPixmaps 的网格布局。但是,如果 QPixmap 中的图像比网格布局的单元格大,它们就会溢出并最终相互重叠。如何使它们自动缩小以适应布局?我到处寻找这个答案,但无法弄清楚。请帮忙,谢谢!
使用class to 的scaled()方法QPixmap将像素图缩小到适合您情况的大小。例如:
scaled()
QPixmap
pix = QPixmap("path/to/image.png") newPix = pix.scaled(w, h, Qt.KeepAspectRatio)
这个片段将缩放pix到wxh。
pix