PDA

View Full Version : QCheckBox with long text label



Ferdous
23rd June 2009, 10:19
Hi,

I'm having difficulty in displaying a check box with long text label. The widget containing this check box has fixed width (insufficient for the long label) and fixed height (more than sufficient space for the long label to be displayed in multiline). Instead of being word-wrapped, the label got cut at the end of first line.

I searched the QCheckBox API for wordWrap property just like QLabel but to no avail. I searched this forum and googled but I found nothing useful for my purpose.

One solution may be - to use a QLabel instead of QCheckBox text and arranging the QCheckBox and QLabel instances in a QHBoxLayout. But one problem surfaces - clicking on QLabel doesn't toggle state of intended QCheckBox. I found no signal to detect clicking on QLabel, though I know it makes little sense.

Please suggest as to how I can have a check box with multiline text label.

wysota
23rd June 2009, 11:19
Subclass QCheckBox and implement word wrapping or subclass QLabel and implement "clickability".

Ferdous
23rd June 2009, 14:16
Can you please elaborate on how to detect click on QLabel?

Lykurg
23rd June 2009, 14:42
QWidget::mousePressEvent() and QWidget::mouseReleaseEvent().

Ferdous
23rd June 2009, 14:45
That's really nice :)

fuzzylogic
29th October 2011, 20:05
Hi wysota. Can you give my a hint how to implement word wrapping by subclassing QCheckBox? I took a look at the qcheckbox.cpp and could not access the QLabel associated with it.

Thanks in advance.