Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.5.0
-
None
-
Windows 10
Tested on MSVC2019 compiler and on MinGW
Description
When using a stylesheet to resize the "checked" indicator in a QListWidget, it seems that the text item isn't correctly aligned with the new indicator size. The text is displayed below the indicator.
This doesn't seem to be an issue on MacOS and was working properly in Qt 5.15.2.
The following code can be used to reproduce the issue:
MainWindow.cpp
// MainWindow.cpp #include "mainwindow.h" #include "./ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); // This stylesheet seems to create the issue: ui->listWidget->setStyleSheet("QListView::indicator{width: 20px; height: 20px;}"); QListWidgetItem* item = new QListWidgetItem("Test Item"); item->setCheckState(Qt::Unchecked); ui->listWidget->addItem(item); } MainWindow::~MainWindow() { delete ui; }
MainWindow.ui
<?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class&amp;gt;MainWindow</class&amp;gt; <widget class="QMainWindow" name="MainWindow"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>800</width> <height>600</height> </rect> </property> <property name="windowTitle"> <string>MainWindow</string> </property> <widget class="QWidget" name="centralwidget"> <layout class="QVBoxLayout" name="verticalLayout"> <item> <widget class="QListWidget" name="listWidget"/> </item> </layout> </widget> <widget class="QMenuBar" name="menubar"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>800</width> <height>21</height> </rect> </property> </widget> <widget class="QStatusBar" name="statusbar"/> </widget> <resources/> <connections/> </ui>
{}Attached images show the behavior in Qt6.5 (incorrect) and in Qt5.15.2 (expected)