Results 1 to 6 of 6

Thread: QCheckBox with long text label

  1. #1
    Join Date
    Sep 2008
    Location
    Bangladesh
    Posts
    17
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default QCheckBox with long text label

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QCheckBox with long text label

    Subclass QCheckBox and implement word wrapping or subclass QLabel and implement "clickability".
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    Ferdous (23rd June 2009)

  4. #3
    Join Date
    Sep 2008
    Location
    Bangladesh
    Posts
    17
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QCheckBox with long text label

    Can you please elaborate on how to detect click on QLabel?

  5. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QCheckBox with long text label


  6. The following user says thank you to Lykurg for this useful post:

    Ferdous (23rd June 2009)

  7. #5
    Join Date
    Sep 2008
    Location
    Bangladesh
    Posts
    17
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QCheckBox with long text label

    That's really nice

  8. #6
    Join Date
    Oct 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QCheckBox with long text label

    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.

Similar Threads

  1. Replies: 15
    Last Post: 31st January 2020, 19:25
  2. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 10:49
  3. how to append text in label
    By wagmare in forum Qt Programming
    Replies: 3
    Last Post: 12th March 2009, 12:06
  4. label with image and text
    By mattia in forum Newbie
    Replies: 1
    Last Post: 7th March 2008, 12:28
  5. Replies: 1
    Last Post: 24th October 2006, 17:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.