本文整理汇总了Python中PyQt4.Qt.QListWidgetItem.setSizeHint方法的典型用法代码示例。如果您正苦于以下问题:Python QListWidgetItem.setSizeHint方法的具体用法?Python QListWidgetItem.setSizeHint怎么用?Python QListWidgetItem.setSizeHint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QListWidgetItem
的用法示例。
在下文中一共展示了QListWidgetItem.setSizeHint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _addToTab
# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setSizeHint [as 别名]
def _addToTab(self, submission, submissionURL, lst):
"""
Add a submission and its representative image to the lst under its tab.
:type submission: praw.objects.Submission
:type submissionURL: str
:type lst: QListWidget
"""
imagePath = submission.representativeImage
if imagePath is not None and imagePath.exists():
item = QListWidgetItem(submissionURL, lst)
item.setTextColor(Qt.transparent)
labelWidget = QLabel()
labelWidget.setOpenExternalLinks(True)
labelWidget.setTextFormat(Qt.RichText)
size = QSize(128, 158)
item.setSizeHint(size)
size = QSize(128, 128)
if imagePath.suffix == ".webm":
imagePath = pathlib.Path("RedditDataExtractor", "images", "videoImage.png").resolve()
pixmap = QPixmap(str(imagePath))
pixmap = pixmap.scaled(size, Qt.KeepAspectRatio)
height = pixmap.height()
width = pixmap.width()
submissionTitle = submissionURL[submissionURL[0:-1].rfind("/") + 1:-1]
labelWidget.setText(
'<a href="' + submissionURL + '"><img src="' + str(imagePath) + '" height="' + str(
height) + '" width="' + str(width) + '"><p>' + submissionTitle)
lst.setItemWidget(item, labelWidget)
示例2: addItem
# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setSizeHint [as 别名]
def addItem(self, collection):
item = QListWidgetItem(self.collectionList)
item.setSizeHint(QSize(36, CLOSED_SIZE))
self.collectionList.addItem(item)
self.collectionList.setItemWidget(item, CollectionItem(self, collection, item))