Results 1 to 4 of 4

Thread: QTextEdit Help !

  1. #1
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    2

    Default QTextEdit Help !

    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~~~
    Last edited by chendy; 31st March 2009 at 16:04.

  2. #2
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    229
    Thanks
    2
    Thanked 29 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTextEdit Help !

    Have a look at the TextInteractionFlags of QTextEdit: http://doc.trolltech.com/4.5/qtexted...tionFlags-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/qtexted...eWrapMode-prop

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

    chendy (1st April 2009)

  4. #3
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit Help !

    and you can customize ScrollBarPolicy like this:
    Qt Code:
    1. QTextEdit * te = new QTextEdit;
    2. te->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    To copy to clipboard, switch view to plain text mode 
    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)
    Attached Images Attached Images
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  5. The following user says thank you to faldzip for this useful post:

    chendy (1st April 2009)

  6. #4
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    2

    Default Re: QTextEdit Help !

    Quote Originally Posted by Boron View Post
    Have a look at the TextInteractionFlags of QTextEdit: http://doc.trolltech.com/4.5/qtexted...tionFlags-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/qtexted...eWrapMode-prop
    i use setTextInteractionFlags(Qt::NoTextInteraction), and it works
    thanks a lot

Similar Threads

  1. QTextEdit Performance handling large paragraphs
    By netuno in forum Qt Programming
    Replies: 14
    Last Post: 1st September 2010, 22:58
  2. Drawing on QTextEdit
    By jgrauman in forum Qt Programming
    Replies: 3
    Last Post: 7th February 2009, 09:40
  3. QTextEdit slow to insert text
    By thomaspu in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2008, 12:05
  4. QTextEdit API questions (plain text)
    By Gaspar in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 06:03
  5. Obtaining clean (x)html from QTextEdit
    By ccf_h in forum Qt Programming
    Replies: 1
    Last Post: 5th February 2006, 14:47

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.