Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QListWidget Item Disappear setViewMode(IconMode) while resizing



  • Hello,
    I have QListWidget and using custom widget, setting setViewMode to QListView.IconMode and while resizing, QListWidget item disappear. This is video: Video
    Thanks!



  • I solved issue! with updating PyQt5 5.14.1 to 5.15.1.


  • Lifetime Qt Champion

    Hi,

    Which version of Qt ?
    On which OS ?
    Can you provide a minimal compilable example that show the behaviour ?



  • @SGaist
    PyQt5 Version 5.14.1
    Windows 10 1909

    Here and thanks for help;

    import sys, os
    from PyQt5 import QtCore, QtWidgets, QtGui
    from PyQt5.Qt import *
    from PyQt5.QtWidgets import QMessageBox, QMainWindow, QWidget, QSizePolicy, QHBoxLayout, QLabel, QPushButton, QTextEdit, \
        QGridLayout, QSpacerItem, QGraphicsOpacityEffect, QMenu, QAction, QApplication, QLineEdit, QTextBrowser, QFileDialog, QDialog, QSizeGrip, QAbstractItemView, QProgressBar, QTableWidgetItem, \
        QCheckBox, QVBoxLayout, QListWidget, QListWidgetItem, QListView
    
    
    class Form(QDialog):
        def __init__(self, parent=None):
            super(Form, self).__init__()
            self.parent = parent
    
        def setupUi(self):
            try:
                self.WID=QWidget()
                self.resize(QSize(800,600))
                self.qv_all = QVBoxLayout(self)
                self.liste = QListWidget()
                self.liste.setStyleSheet(
                    "QListWidget{background-color:transparent}QListWidget:item{border:2px solid gray;border-radius:10px}QPushButton{border-bottom-left-radius: 7px;border-bottom-right-radius: 7px;background-color:transparent}" )
                self.liste.setSelectionMode(QAbstractItemView.SingleSelection)
    
                self.liste.setMovement(QListView.Static)
                self.liste.setViewMode(QListView.IconMode)
                
                self.liste.setSpacing(5)
                self.liste.setResizeMode(self.liste.Adjust)
    
                self.liste.setContextMenuPolicy(Qt.CustomContextMenu)
    
                self.liste.setSpacing(15)
                self.qv_all.addWidget(self.liste)
                for i in range(3):
                    wid = QListWidgetItem()
                    wid.setText("")
                    #wid.setData(Qt.UserRole + 1, veri)
                    wid.setFont(QFont('Arial', 12))
                    wid.setSizeHint(QSize(256, 256))
                    self.liste.addItem(wid)
                    # wid.setData(Qt.DecorationRole,pix.scaled(128 + 32, 96, Qt.IgnoreAspectRatio,Qt.SmoothTransformation))
    
    
                    btnBaslat = QPushButton("btn_1")
                    btnBaslat.setFixedHeight(25)
                    btnBaslat.setStyleSheet("background-color:rgb(255,68,10);color:black;border-radius:10px")
    
                    widCustom = QPushButton()
                    QVToplam = QVBoxLayout(widCustom)
                    lblName = QLabel("<font color='black'>%s</font>" % ("caption"), self)
                    QVToplam.addWidget(lblName)
    
                    lblImage = QLabel()
                    lblImage.setAlignment(Qt.AlignCenter)
                    #pix = QPixmap('url:("C:/Users/User/Desktop/wallpaper/891884.jpg")')
                    pix = self.style().standardIcon(getattr(QStyle, "SP_MediaPlay")).pixmap(QSize(128,128))
                    lblImage.setPixmap(QPixmap(pix).scaled(128 + 32, 32 + 128, Qt.IgnoreAspectRatio, Qt.SmoothTransformation))
                    QVToplam.addWidget(lblImage)
    
                    lbl_bilgi_Sure = QLabel("<font color='red'>Oynanma Suresi:</font>")
                    lbl_bilgi_Sure.setAlignment(Qt.AlignCenter)
    
    
    
                    QVToplam.addWidget(lbl_bilgi_Sure)
                    QVToplam.addWidget(btnBaslat)
    
                    self.liste.setItemWidget(wid, widCustom)
    
                
            except Exception as err:
                print("SetupUi: %s"% str(err))
    
    
    if __name__ == "__main__":
        app = QApplication(sys.argv)
        frm= Form()
        frm.setupUi()
        frm.show()
        
        sys.exit(app.exec())
    


  • I solved issue! with updating PyQt5 5.14.1 to 5.15.1.


Log in to reply