Problem with text eliding on QToolButtons since Qt5.12 when text spans multiple lines
gde23 last edited by
I have some problem with the elided text behaviour since Qt5.12.
Following example which is just a QToolButton with a 2-lined text and an icon.
QToolButton* button = new QToolButton(parent); button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); button->setFixedWidth(100); button->setFixedHeight(200); button->setIconSize(QSize(50, 50)); QIcon icon = style()->standardIcon(QStyle::SP_ComputerIcon); button->setIcon(icon); button->setText("TestTest\nTestTest"); centralWidget()->layout()->addWidget(button);
The result looks like this:
It seems that the function to check if the text fits the button test against the whole string and then replaces the \n with ... which results in a text that does not fit the button although the text would fit, if just the newline would be applied as intended.
For some reason the problem only appears for buttons that have an icon set.
Is there some way to disable the eliding completely?
What OS are you running on ?
Can you provide the full sample code to reproduce this ?
gde23 last edited by gde23
The system is Debian Stretch with KDE and Qt5.12
Minimal working example see here
Can't reproduce that on macOS.
Can you test if you get the same result with your Debian provided Qt ?
Windows 10, Qt5.12
But for multi-line texts the issue still remains. Will need to fix it :(
It's a pity that every item is using it's own drawing stuff instead a common one (I fixed such issues for QTable/Tree/List items some times ago in another place...)
for reference and if someone wants to test it: https://codereview.qt-project.org/#/c/248836/