Results 1 to 3 of 3

Thread: How to display text from file and program output in QTextEdit?

  1. #1
    Join Date
    Sep 2012
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to display text from file and program output in QTextEdit?

    Hi everyone, I have a really simple problem that I could use some help with. I wrote a program which spell checks a plain text file and can do things like keep track of the most commonly used words / most commonly misspelled words. I've already implemented all of the functionality in a class called Dictionary. My problem is in displaying the contents of these files and some information obtained from the program in QTextEdit windows (and why we're using that rather than a normal display window, I don't know). I don't have any prior experience with GUI applications.

    I don't need to do anything in the windows except display the contents of the file, with misspelled words in red, and show some program output in separate windows. I've been searching Google and reading the Qt documentation for about the past hour after finishing up the guts of the program but I can't find a solid tutorial for this, so if anyone could help me out I'd really appreciate the assistance.

  2. #2
    Join Date
    Jun 2010
    Location
    Pretoria, South Africa
    Posts
    22
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to display text from file and program output in QTextEdit?

    Perhaps the QSyntaxHighlighter might be your answer. There's a tutorial about how to use it. Check it out in the Qt Assistant or google it.

    You can get the QTextDocument* directly from your QTextEdit, so the extra coding should be minimal on your part.

  3. #3
    Join Date
    Sep 2012
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to display text from file and program output in QTextEdit?

    Thanks for the response, I ended up using my display function to format the text in HTML for color.

Similar Threads

  1. Display an output buffer (text stream) in QWidget
    By nomiz in forum Qt Programming
    Replies: 8
    Last Post: 30th June 2011, 09:44
  2. open exe file or output of another program
    By sandya in forum Newbie
    Replies: 1
    Last Post: 7th June 2011, 07:21
  3. Replies: 9
    Last Post: 28th March 2011, 22:51
  4. Display pdf file in QTextEdit
    By toutarrive in forum Qt Programming
    Replies: 8
    Last Post: 7th August 2009, 16:51
  5. output while executing should be redirected to text file
    By AnithaRagupathy in forum Qt Programming
    Replies: 3
    Last Post: 13th October 2007, 10:33

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.