Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTextEdit freeses
QtWS25 Last Chance

QTextEdit freeses

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zerg2011
    wrote on last edited by
    #1

    Hi

    I have QTextEdit and file which size is ~1 GB.

    As I read this file from the stream , and append readed data into
    the QTextEdit in main thread , the main gui event loop freezes ,
    and QTextEdit freezes also , so user feel sad.

    As far as I understand the problem is in append function who works too long.

    As I move readAll and append into another thread , program crashes by obvious
    reason - two threads (GUI thread and thread-appender) trys to work with QTextEdit simulteneously.

    I can't move QTextEdit from main thread into the thread-appender , becouse it's GUI object ,
    and so he needs GUI event loop.

    So my question is : how to avoid main event loop ( and my widget ) freezing ,
    during the large file loading into QTextEdit.

    Is exists probably advanced text edit widget , who allow reading in other thread ?

    Or may be exsists the way to isolate QTextEdit from main event loop temporarily ,
    and avoid problem with simultaneous access ?

    Or may be exists in Qt the correct , standard way to synchronize access to GUI widget
    from my thread and event loop.

    A bit of code , just to clarify

    @
    QTextStream in ( file ) ;
    QTextEdit *textEdit_ ;

    Qstring buf = in. readAll( ) ;
    textEdit_ -> append( buf ) ;
    @

    Thanks.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      miroslav
      wrote on last edited by
      #2

      You can use a thread to load the file contents (lines 1 and 4 in your example), and only show progress information in the main thread. The question whether 1GB of text makes sense in a text edit field is independent of that approach :-)

      Mirko Boehm | mirko@kde.org | KDE e.V.
      FSFE Fellow
      Qt Certified Specialist

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        zerg2011
        wrote on last edited by
        #3

        Good idea. Maybe it works

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved