View Full Version : QTextEdit Help !
chendy
31st March 2009, 16:00
Hello,
I use a QTextEdit to display some texts, setting it to ReadOnly, but I want the texts cannot be selected, just like QLabel. As well, there should be scrollbar when the dlg is too small.
I am a beginner in qt4, PLZ help me.
thanks~~~
:)
Boron
31st March 2009, 16:52
Have a look at the TextInteractionFlags of QTextEdit: http://doc.trolltech.com/4.5/qtextedit.html#textInteractionFlags-prop
A vertical scrollbar is added automatically when the text is higher than the height of the QTextEdit.
If you want a horizontal scrollbar you have to configure the LineWrapMode: http://doc.trolltech.com/4.5/qtextedit.html#lineWrapMode-prop
faldzip
31st March 2009, 22:18
and you can customize ScrollBarPolicy like this:
QTextEdit * te = new QTextEdit;
te->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
and that code gives you always visible scrollbar.
Another thing is that you can put QLabel in QScrollArea if you want to have just a QLabel functionality (look at screenshot - left is QTextEdit, right is QScrollArea with QLabel inside)
chendy
1st April 2009, 03:18
Have a look at the TextInteractionFlags of QTextEdit: http://doc.trolltech.com/4.5/qtextedit.html#textInteractionFlags-prop
A vertical scrollbar is added automatically when the text is higher than the height of the QTextEdit.
If you want a horizontal scrollbar you have to configure the LineWrapMode: http://doc.trolltech.com/4.5/qtextedit.html#lineWrapMode-prop
i use setTextInteractionFlags(Qt::NoTextInteraction), and it works
thanks a lot
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.