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:
Code:
foreach (filename, list) {
// So something.
textEdit->append("Some text describing what I'm doing.");
qDebug("Some text describing what I'm doing.");
QFile file(currentDir.
absoluteFilePath(fileName
));
file.copy(newPath);
}
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!
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]
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!
Re: QTextEdit doesn't append text
Why would the loop stop if you close the window?
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!
Re: QTextEdit doesn't append text
You won't receive a close event if you block the event loop.
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...
Re: QTextEdit doesn't append text
Did you read the article I pointed you to? It deals with solutions to problems such as yours.