Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QCheckBox word-wrap

Tags:

qt

pyqt

Is there a way to wrap text in QCheckBox like it is done with QLabel?

label = QLabel( QString.fromUtf8('long text in here'))
label.setWordWrap(True)

I tried \n which will add a linebreak but this is not dynamic if I resize the window.

like image 977
Germar Avatar asked May 09 '13 00:05

Germar


2 Answers

It seems there is a feature request for this at https://bugreports.qt.io/browse/QTBUG-5370.

The issue is not closed, so likely this feature is not implemented. This means that it is not currently possible to add word wrap to QCheckBox.

You can try various workarounds, such as having an empty-text QCheckBox and a QLabel to the right, or try putting a shorter text for the checkbox, with a label below it with the long explanation.

like image 73
sashoalm Avatar answered Nov 01 '22 14:11

sashoalm


You can develop a Custom widgets for QtDesigner to use this feature graphically (or not).

CheckBoxWordWrap (dynamic when resize):

CheckBoxWordWrap

In QtDesigner:

CheckBoxWordWrap plugin
CheckBoxWordWrap properties

You can also use the class and modify it if the behavior is not exactly what you want.

like image 40
thibsc Avatar answered Nov 01 '22 14:11

thibsc