Results 1 to 8 of 8

Thread: QTextEdit doesn't append text

  1. #1
    Join Date
    Jan 2010
    Posts
    190
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default QTextEdit doesn't append text

    Hi! I created I loop in which I copy files from a location to a another. When I copy one file, I inform the user of the file name. Unfortunately, it seems that if I inform the user by placing a qDebug output, the string is written correclty, if I use the method append of QTextEdit, nothing is written. I simply have this:

    Qt Code:
    1. QString filename;
    2. foreach (filename, list) {
    3. // So something.
    4. textEdit->append("Some text describing what I'm doing.");
    5. qDebug("Some text describing what I'm doing.");
    6. QFile file(currentDir.absoluteFilePath(fileName));
    7. file.copy(newPath);
    8. }
    To copy to clipboard, switch view to plain text mode 

    In this situation, qDebug writes the sentence in the right place, but textEdit shows nothing of what it should. Maybe the application is too busy to do anything, including writing something? Any way I can do what I need?
    Thanks!

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

    Default Re: QTextEdit doesn't append text

    You are blocking the event loop so the widget can't update itself.
    [wiki]Keeping the GUI Responsive[/wiki]
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2010
    Posts
    190
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QTextEdit doesn't append text

    Thank you very much. This solved the issue.
    There is only one thing I'm noticing: even if I close my QMainWindow it seems the loop is not stopped... Any idea why?
    Thanks!

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

    Default Re: QTextEdit doesn't append text

    Why would the loop stop if you close the window?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jan 2010
    Posts
    190
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QTextEdit doesn't append text

    Right... But I also tried to call the quit() method of QApplication when I get the closeEvent of my main window, but nothing happens. Shouldn't that be sufficient?
    Thanks for your help!

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

    Default Re: QTextEdit doesn't append text

    You won't receive a close event if you block the event loop.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Jan 2010
    Posts
    190
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QTextEdit doesn't append text

    Seems difficult to simply close an application...
    I tried with:
    qApp->setQuitOnLastWindowClosed(true);
    but seems this is not quitting the event loop as well... Maybe my only option is to switch to using a worker thread...

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

    Default Re: QTextEdit doesn't append text

    Did you read the article I pointed you to? It deals with solutions to problems such as yours.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. how to append text in label
    By wagmare in forum Qt Programming
    Replies: 3
    Last Post: 12th March 2009, 11:06
  2. Cannot append to QFile using QIODevice::Append
    By philwinder in forum Qt Programming
    Replies: 4
    Last Post: 17th November 2008, 09:09
  3. QTextEdit + paste rich text as plain text only
    By Yong in forum Qt Programming
    Replies: 2
    Last Post: 6th February 2008, 16:45
  4. How to add a new word to QTextEdit with "append"
    By yagabey in forum Qt Programming
    Replies: 8
    Last Post: 6th January 2008, 11:50
  5. QTextEdit::append help
    By tho97 in forum Qt Programming
    Replies: 1
    Last Post: 29th November 2007, 07:10

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.