【问题标题】:How to increase the size of a thumbnail in QListWidget如何在 QListWidget 中增加缩略图的大小
【发布时间】:2015-04-01 14:42:50
【问题描述】:

问题 => 我想创建一个 QlistWidgetItem 对象,其中包含图像列表以及它们的缩略图,其尺寸比我当前拥有的尺寸相对较大(类似于“中等图标”或 Windows 资源管理器中的“大图标”选项)

到目前为止的进展 => 我已经设法找出如何创建列表,但除了图标之外的所有图标都太小了。

我尝试过的 => 我尝试过更改列表项的字体大小,假设 cld 也会使字体按比例变大。没用。根据另一位在线博主,我还尝试使用(PIL 的图像)设置缩略图的大小,但效果不佳。

代码片段 => #从 PIL 导入 Image 和 ImageQt 并导入 QtGui 和 QtCore

    testimages = glob.glob(dirname +  "/*.jpg")
    # Create a list item for each image file,
    # setting the text and icon appropriately
    for image in testimages:
        picture = Image.open(image)
        picture.thumbnail((128,128), Image.ANTIALIAS)
        icon = QIcon(QPixmap.fromImage(ImageQt.ImageQt(picture)))
        item = QListWidgetItem(image, self)
        item.setIcon(icon)
        fonter = QFont("Times New Roman")
        fonter.setPointSize(14)
        item.setFont(fonter)

希望你们能帮帮我。 :)

【问题讨论】:

    标签: python pyqt4 qlistwidgetitem


    【解决方案1】:

    在您的QListWidget 上使用setIconSize 定义您想要的大小。

    【讨论】:

    • 我一直在使用 QListWidgetItem(它没有该属性)而不是 QListWidget。我将尝试使用 QListWidget。非常感谢! :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-22
    • 1970-01-01
    • 1970-01-01
    • 2019-12-01
    相关资源
    最近更新 更多