TextPreview: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
(No difference)

Revision as of 17:55, 14 January 2015

TextPreview

This is an example of Qt Gui Application to read a specified number of lines or all lines from a text file, whose character set is automatically detected and displayed.

The program was developed with Qt Creator 2.7.1, and ran successfully with Qt 4.8.4 on Ubuntu 13.04, linking to a universal character detection library libuchardet available in package as libuchardet-dev. Lines for debugging are intentionally left so as to be helpful in checking the program.

Souce code

TextPreview.pro

#————————————————————————-
#

  1. Project created by QtCreator 2013-09-04T00:11:05


# #————————————————————————-

widget.h

main.cpp

widget.cpp

widget.ui

Gui design (widget.ui)

Picture of Gui Design in Qt Creator for widget.ui

Example

Ran the program.

Picture of a widget window when the TextPreview program is launched.

Changed the number of lines to 2, and hit the Preview button. Chose a text file in a dialog box.

Picture of the widget window after pushing the preview button and choosing a text file.

The file’s path and character set are shown, and the first 2 lines, as specified, are shown in the plain text box.

Links

  1. TextPreview at GitHub [github.com]

Categories: