Results 1 to 13 of 13

Thread: QTextEdit loading takes long time

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2006
    Posts
    788
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    49
    Thanked 48 Times in 46 Posts

    Default Re: QTextEdit loading takes long time

    Build a less (unix http://linux.about.com/library/cmd/blcmdl1_less.htm ) similar function .... and limit him to 20-30 line....

    and as slot a vertical slider...... tickintervall 30-20

    and get line from file ..... chanche this code to get line start and end...

    is very fast....

    Qt Code:
    1. QString Sqlitedb::file_get_line(QString fullFileName,int linenr)
    2. {
    3. QString result;
    4. QFile file( fullFileName );
    5. if( file.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
    6. QTextStream in( &file );
    7. int currentLineNr = 0; // or 1
    8. while( ! in.atEnd() ) {
    9. QString line( in.readLine() );
    10. if( currentLineNr == linenr ) { /* only rewrite here .. lineNr */
    11. result = line;
    12. break;
    13. }
    14. currentLineNr += 1;
    15. /*qDebug() << "### linerr " << currentLineNr; */
    16. }
    17. }
    18. return result;
    19. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QTextEdit loading takes long time

    This would be a crude and nasty hack which would break all of QTextEdit functionality like redo/undo, searching for text, etc. The proper way is to use QTextDocument. Trust me on that If in doubt, read the docs.

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

    sreedhar (20th June 2006)

  4. #3
    Join Date
    Jul 2010
    Posts
    6
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: QTextEdit loading takes long time

    Comment. I meet same question.

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
  •  
Qt is a trademark of The Qt Company.