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.
- Project created by QtCreator 2013-09-04T00:11:05
Gui design (widget.ui)
Ran the program.
Changed the number of lines to 2, and hit the Preview button. Chose a text file in a dialog box.
The file’s path and character set are shown, and the first 2 lines, as specified, are shown in the plain text box.
- TextPreview at GitHub [github.com]