On 05/05/2021 21:14, Torsten Paul wrote:
On 05.05.21 12:45, Phil Thompson wrote:
The "desired" size is the size hint of a QListWidget which
works fine for me. In particular I don't see any scrollbars.

Hmm, I tried with a tiny test case on my system and it's not
actually 100x100 but the result is still pretty unusable when
setting the editor to a bigger font. Is that default maybe
based on the default font size?

Test system:
- Dell XPS 13 with 4k display
- Debian/Testing with Qt 5.15.2, QScintilla 2.11.6

Screenshot and sample project based on Qt example project
https://doc.qt.io/qt-5/qtwidgets-mainwindows-application-example.html
attached.

Run via: qmake && make && ./application

Screenshot is just pressing uppercase P after the window is
shown.

Can you try the attached patch?

Phil
diff -r 0e8a95ee3197 qt/ListBoxQt.cpp
--- a/qt/ListBoxQt.cpp	Thu Mar 04 12:34:35 2021 +0000
+++ b/qt/ListBoxQt.cpp	Thu May 06 11:39:22 2021 +0100
@@ -8,6 +8,8 @@
 
 #include <stdlib.h>
 
+#include <QApplication>
+
 #include "SciClasses.h"
 #include "Qsci/qsciscintilla.h"
 
@@ -64,10 +66,22 @@
 
     if (slb)
     {
-        QSize sh = slb->sizeHint();
+        int rows = slb->count();
+
+        if (rows == 0 || rows > visible_rows)
+            rows = visible_rows;
+
+        int row_height = slb->sizeHintForRow(0);
+        int height = (rows * row_height) + (2 * slb->frameWidth());
 
-        rc.right = sh.width();
-        rc.bottom = sh.height();
+        int width = slb->sizeHintForColumn(0) + (2 * slb->frameWidth());
+
+        if (slb->count() > rows)
+            width += QApplication::style()->pixelMetric(
+                    QStyle::PM_ScrollBarExtent);
+
+        rc.right = width;
+        rc.bottom = height;
     }
 
     return rc;

Reply via email to