QComboBox bug in Qt5.15
-
@JonB
FYI, You can capture image for combobox popup using gimp (File > Create > Screenshot). You are unable to capture using the PrtScrn key since the combobox grabbed the keyboard focus.@sjlee
I installed gimp. Maybe you can make it work, I can't, at best I get a black rectangle captured for the combo box! I think/hope you can manage without a screenshot from my explanation, maybe you can reproduce same (if you use same default fonts/sizes etc. as I get). -
Please try your code with "landscape & this" and "portrait & this" items instead of ro/rw. I mean longer string than its width.
Thank you.
@sjlee said in QComboBox bug in Qt5.15:
Please try your code with "landscape & this" and "portrait & this" items instead of ro/rw. I mean longer string than its width.
Thank you.
@sjlee You mean text that is longer than the combo box width, like "Text that is too long" that you already have an example of? How about you provide your code that demonstrates the alleged bug.
-
@ChrisW67
I too have Qt 15.5.3. I am under Ubuntu 22.04, with GNOME desktop. I think you are different because of the "X" in the top left of your combo, I do not get this, I think you are using a different window manager?You will have to bear with my explanations, because I cannot figure how to take screen shots with a combo dropped down :(
I do not get the behaviour you show with your code. When the "Text that ..." is added I get no ellipsis, instead the whole line is shown but with the dropped-down portion being allowed to be wider than the combo box width, so it sticks out right below. Just saying.
@sjlee
Your instructions are most unclear as to exactly what you want the whole thing changed to. I won't go through all the combinations I tried as to what precisely you might mean, they behave in various ways. However, I did come across one oddity which just might be a clue to what is going on and the oddity of&
. Try exactly this:int main(int argc, char **argv) { QApplication app(argc, argv); QComboBox *cb1 = new QComboBox(); cb1->addItem(QStringLiteral("portrait & this")); cb1->show(); QTimer::singleShot(5000, [=]() { cb1->addItem(QStringLiteral("landscap & this")); } ); return app.exec(); }
Note that my
landscap
[sic.] is deliberately written like this. Now when I do this if you look very closely at the appended item I seelandsc..._this
The space before
this
is an underlined space. That implies [to me] that at some level Qt is treating the&
[ampersand followed by space] as shortcut indicator, not a literal ampersand. And my guess is that somewhere in the ellipsisation code this "incorrect interpretation" is made. But not always, because it does not happen in other cases, e.g.landscape & this
shows aslandsca...& this
, no shortcut. Maybe something like "if&
is the last character "chopped off" by inserting ellipses then it incorrectly treats the following, preserved character as having been marked as a shortcut by the removed&
preceding it".I don't know whether this helps! But maybe there is indeed some special treatment of
&
going on here, only showing up under special circumstances?@JonB said in QComboBox bug in Qt5.15:
I too have Qt 15.5.3. I am under Ubuntu 22.04, with GNOME desktop. I think you are different because of the "X" in the top left of your combo, I do not get this, I think you are using a different window manager?
@JonB
It is KDE (so kwin). It's a pain in the backside to capture the open combo box there also. With a standalone combo box the window manager will have input into size constraints and the constraint it imposes here causes text to elided. In the OP's screen shot the size of the combo box is constrained to some degree by the table cell the delegate is opening it over, and by the options set, and text is elided. This is exactly what was shown in the OP's opening screen shot. The ampersand was completed elided and there was no errant underline.The oddity you noticed with the ampersand I will try to reproduce when I am back at my Linux box.
-
@JonB said in QComboBox bug in Qt5.15:
I too have Qt 15.5.3. I am under Ubuntu 22.04, with GNOME desktop. I think you are different because of the "X" in the top left of your combo, I do not get this, I think you are using a different window manager?
@JonB
It is KDE (so kwin). It's a pain in the backside to capture the open combo box there also. With a standalone combo box the window manager will have input into size constraints and the constraint it imposes here causes text to elided. In the OP's screen shot the size of the combo box is constrained to some degree by the table cell the delegate is opening it over, and by the options set, and text is elided. This is exactly what was shown in the OP's opening screen shot. The ampersand was completed elided and there was no errant underline.The oddity you noticed with the ampersand I will try to reproduce when I am back at my Linux box.
@JonB Whatever that behaviour is, it is sensitive to the environment. This is what your code does by default in my KDE environment:
If I subsequently narrow the window as much as the window decorations allow:
Note, no spurious underscore. I fiddled a bit but could not reproduce it (Fusion or Windows style). Qt 6.4.2 did something different again -
@JonB Whatever that behaviour is, it is sensitive to the environment. This is what your code does by default in my KDE environment:
If I subsequently narrow the window as much as the window decorations allow:
Note, no spurious underscore. I fiddled a bit but could not reproduce it (Fusion or Windows style). Qt 6.4.2 did something different again@ChrisW67
For one, thing you are using both a different font and a different window-look. Understandably. I can only suggest if you want to try to replicate mine, you find a string such that Qt puts ellipsis into it to shorten and the last character of what was removed is the&
character. So the eliding producesabc... def
from what used to be something likeabc123 & def
.Meanwhile I might be more confident about producing a screen shot from a dropped-down combo so will have another go at producing that for pasting soon :)
-
For what it's worth, I am also seeing this strange behavior, and it seems to not relate to text eliding in the contained
QAbstractItemView
, either that, or theQAbstractItemView
is ignoring mysetTextElideMode(Qt::ElideNone)
call.The project in question I am working with is
apitrace
, and I can reproduce this behavior in the app build, but not in just a standalone example showing just the dialog that contains this combo box.The
&
is replaced with...
even when I callcombo->view()->setTextElideMode(Qt::ElideNone)
.This occurs for me in Qt 5.15.14, and Qt 6.5.1.
To see my attempts to reproduce the issue outside of qapitrace, and to explain how to reproduce this in qapitrace, clone this small repo and follow the README.md:
https://github.com/keithel/qapitrace-combobox-elide-bug -
For what it's worth, I am also seeing this strange behavior, and it seems to not relate to text eliding in the contained
QAbstractItemView
, either that, or theQAbstractItemView
is ignoring mysetTextElideMode(Qt::ElideNone)
call.The project in question I am working with is
apitrace
, and I can reproduce this behavior in the app build, but not in just a standalone example showing just the dialog that contains this combo box.The
&
is replaced with...
even when I callcombo->view()->setTextElideMode(Qt::ElideNone)
.This occurs for me in Qt 5.15.14, and Qt 6.5.1.
To see my attempts to reproduce the issue outside of qapitrace, and to explain how to reproduce this in qapitrace, clone this small repo and follow the README.md:
https://github.com/keithel/qapitrace-combobox-elide-bug@kkyzivat if you have a simple reproducer then please create a bug report and post the link here.
-
@kkyzivat if you have a simple reproducer then please create a bug report and post the link here.
@Christian-Ehrlicher
Oh, of course. I just haven't gotten there yet. Simple reproducer doesn't seem to be reproducing the issue (though I am using a different Qt build, one part of Pypi Qt for Python build). I should just rewrite my reproducer in C++ to test apples to apples.I find writing these simple reproducers in Python is often quicker.
-
@Christian-Ehrlicher
Oh, of course. I just haven't gotten there yet. Simple reproducer doesn't seem to be reproducing the issue (though I am using a different Qt build, one part of Pypi Qt for Python build). I should just rewrite my reproducer in C++ to test apples to apples.I find writing these simple reproducers in Python is often quicker.
@kkyzivat said in QComboBox bug in Qt5.15:
I find writing these simple reproducers in Python is often quicker
Maybe, but it makes debugging for the dev harder as he has to create a c++ test case in most cases first. So providing a small c++ reproducer will likely result in an earlier bugfix.
-
@kkyzivat said in QComboBox bug in Qt5.15:
I find writing these simple reproducers in Python is often quicker
Maybe, but it makes debugging for the dev harder as he has to create a c++ test case in most cases first. So providing a small c++ reproducer will likely result in an earlier bugfix.
@Christian-Ehrlicher Yeah - I often will rewrite it in C++ before attaching.
-
For what it's worth, I am also seeing this strange behavior, and it seems to not relate to text eliding in the contained
QAbstractItemView
, either that, or theQAbstractItemView
is ignoring mysetTextElideMode(Qt::ElideNone)
call.The project in question I am working with is
apitrace
, and I can reproduce this behavior in the app build, but not in just a standalone example showing just the dialog that contains this combo box.The
&
is replaced with...
even when I callcombo->view()->setTextElideMode(Qt::ElideNone)
.This occurs for me in Qt 5.15.14, and Qt 6.5.1.
To see my attempts to reproduce the issue outside of qapitrace, and to explain how to reproduce this in qapitrace, clone this small repo and follow the README.md:
https://github.com/keithel/qapitrace-combobox-elide-bugOk - this seems to actually be a bug in Qt introduced in Qt 5.15.3 - however it is resolved some time between Qt 6.0.0 and 6.5.1.
I retested with Qt 6.5.1, and it seems not to reproduce there.
The bug shows up in Qt 5.15.3, but not in Qt 5.15.2 and not in Qt 6.5.1.
Given this, it isn't worth making a bug report about it, since it is already fixed in Qt 6.
If anyone reading this is interested to test, I have updated my bug exploration repo with this new info:
https://github.com/keithel/qapitrace-combobox-elide-bug