Originally Posted by
marcel
Use:
textEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
textEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
To copy to clipboard, switch view to plain text mode
I am able to remove the scrollBar now,
But How to resize the TextEdit based on the content of the edit...
what is the equivalent functionality of heightForWidth
text->resize(640, 30);
text->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
qDebug() << "before " <<text->width();
text->setText("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBB
BBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRRRGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
GGGGGGGGGGGGGGGGGGGGGGGGGJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
JJJJKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK");
qDebug() << "After " <<text->width();
int ht = text->heightForWidth(text->width());
if(ht > 20)
text->resize(text->width(), ht);
QTextEdit *text = new QTextEdit(window);
text->resize(640, 30);
text->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
qDebug() << "before " <<text->width();
text->setText("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBB
BBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRRRGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
GGGGGGGGGGGGGGGGGGGGGGGGGJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
JJJJKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK");
qDebug() << "After " <<text->width();
int ht = text->heightForWidth(text->width());
if(ht > 20)
text->resize(text->width(), ht);
To copy to clipboard, switch view to plain text mode
In the above code the width and height remain the same before and after the text is inserted....
How could I resize the TextEdit based on content .
And How can I get the total number of lines in TextEdit.
Thanks
Bookmarks