I need to set the wordwrap policy of Qlabel so that it wraps the text anywhere and not just the word-breaks. I have read that the same can be done in QTextEdit. Is this thing possible with QLabel?
Printable View
I need to set the wordwrap policy of Qlabel so that it wraps the text anywhere and not just the word-breaks. I have read that the same can be done in QTextEdit. Is this thing possible with QLabel?
I have a feeling that it might be easier to write a custom label widget with the help of QTextLayout than to hack QLabel for this.
I am again back on the same problem..
Somehow I am not able to figure out how to use the QTextLayout along with QLabel so that the text on the label is displayed according to the set WordWrap policy..
thanks in advance for any kind of help
Perhaps you could simply use QTextEdit?
Code:
{ Q_OBJECT public: { // make it look and feel like an ordinary label setReadOnly(true); setPalette(pal); // wrap anywhere, adjust minimum height on the fly connect(document()->documentLayout(), } private slots: void adjustMinimumSize(const QSizeF& size) { setMinimumHeight(size.height() + 2 * frameWidth()); } };