Details
-
Bug
-
Resolution: Incomplete
-
Not Evaluated
-
None
-
5.9.6
-
None
Description
When setting the view mode to IconMode, and the selection behavior to SelectRows the selection highlight appears to be off (first image). However, if I then set the text alignment to AlignLeft, the selection highlight seems to be correct (second image).
Minimal working example included below. Sorry its it Python with PyQt. Uncomment the commented line to see the the selection change.
from PyQt5 import QtCore, QtGui, QtWidgets app = QtWidgets.QApplication(sys.argv) list_widget = QtWidgets.QListWidget() list_widget.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) list_widget.setIconSize(QtCore.QSize(100, 100)) list_widget.setViewMode(QtWidgets.QListView.IconMode) for image, text in [("../ftw-data/themes/BlueBurst.png", "Blue Burst"), ("../ftw-data/themes/Clouds.png", "Clouds"), ("../ftw-data/themes/Wheat.png", "Wheat")]: item = QtWidgets.QListWidgetItem(text, list_widget) # item.setTextAlignment(QtCore.Qt.AlignLeft) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(image), QtGui.QIcon.Normal, QtGui.QIcon.Off) item.setIcon(icon) item.setSizeHint(QtCore.QSize(200, 150)) list_widget.show() sys.exit(app.exec_())