Results 1 to 6 of 6

Thread: QTextEdit

  1. #1
    Join Date
    Sep 2008
    Posts
    18
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question QTextEdit

    How would you output text dynamically to QTextEdit to be viewed by the user?

  2. #2
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QTextEdit

    What do you mean by dynamically?

  3. #3
    Join Date
    Sep 2008
    Posts
    18
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QTextEdit

    I mean that if you want to say solve an equation x = 4(6+5), you can stop the solution after solving 6+5 and display x = 4(11). Then continue and display x=44. This is not the actual type of equation that I'm trying to solve; however this is what I mean by "dynamic". The following is another example.

    Suppose you input the equation x = 5 + 2(25 - 15/y), and you set y to 3...
    I want the QTextEdit to EVENTUALLY display

    x = 5 + 2(25 - 15/y)
    x = 5 + 2(25 - 15/3)
    x = 5 + 2(25 - 5)
    x = 5 + 2(20)
    x = 5 + 40
    x = 45

    I was also wondering on how you could incorporate a stop. In which the next step is displayed only if the user chooses to continue.

    x = 5 + 2(25 - 15/y)
    ask if continue

    x = 5 + 2(25 - 15/3)
    ask if continue

    x = 5 + 2(25 - 5)
    ask if continue

    x = 5 + 2(20)
    ask if continue

    x = 5 + 40
    ask if continue

    x = 45

    Does that make sense?
    Last edited by RY; 15th October 2008 at 07:18.

  4. #4
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit

    Sounds like a task for a custom widget as QTextEdit would make it complicated to add the stop feature and bring unnecessary complexity (as you don't need to edit the text once written right?). A simple scroll area with a QStringList of lines to display should do. Then just add a string to the list to display a new line (and update display) and reimplement the keyPressEvent to add the "stop" feature.
    Current Qt projects : QCodeEdit, RotiDeCode

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

    RY (15th October 2008)

  6. #5
    Join Date
    Sep 2008
    Posts
    18
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QTextEdit

    Correct, we don't need to edit the text once it is written.

    It sounds like you know what I mean. Do you have some simple example code of your explanation? What classes and functions are you thinking of?

  7. #6
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit

    I've basically rewritten QTextEdit from scratch (removing some features and adding new ones) in my QCodeEdit library and what I did was that : subclass QAbstractScrollArea and reimplement event handlers just like QTextEdit does. The same approach should do for you, except that it will be simpler as you do not need to handle much interaction.

    I just wrote a quick example for educationnal purpose (and because I wanted to do something more entertaining than linear algebra assignements) : http://edyuk.org/misc/scrollingdisplay.tar.gz

    It basically appends lines made of 30 random digits to a scrolling display, at a rate of one new line every 200ms (i.e 5 lines per seconds)

    The example code is available under BSD license (i.e free to use for any purpose with (almost) no restrictions). Proper management of the horizontal scrollbar and further improvements are left as an exercise to the reader.
    Current Qt projects : QCodeEdit, RotiDeCode

Similar Threads

  1. QTextEdit Performance handling large paragraphs
    By netuno in forum Qt Programming
    Replies: 14
    Last Post: 1st September 2010, 22:58
  2. QTextEdit and cursor
    By newplayer in forum Qt Programming
    Replies: 1
    Last Post: 30th July 2008, 23:24
  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. Painting to QTextEdit
    By gesslar in forum Qt Programming
    Replies: 8
    Last Post: 18th February 2006, 18: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.