PDA

View Full Version : Can't see any text append in UI?



SamT
9th April 2011, 07:42
I got a problem to use the QTextEdit with append function.

MainWindow::ui->textDumpMessage->append("Before the QStringList fileList line");
QStringList fileList = QFileDialog::getOpenFileNames(this, tr("Open CSV"), QDir::currentPath(), tr("CSV File *.csv"));
if (fileList.isEmpty())
{
return false;
}
MainWindow::ui->textDumpMessage->append("After the QStringList fileList line");
qDebug() << "Load csv";

the QTextEdit can show first append text but fail to get the second append text. I doubt the problem is on QStringList or QFileDialog. Does any body encounter the same issue?

I use QT 4.7.2 with mingw32 on windows XP.

jwjoshua
9th April 2011, 07:50
Hi, try inserting a new append inside the isEmpty() check, so that you can know whether the execution gets there: i.e:



MainWindow::ui->textDumpMessage->append("Before the QStringList fileList line");
QStringList fileList = QFileDialog::getOpenFileNames(this, tr("Open CSV"), QDir::currentPath(), tr("CSV File *.csv"));
if (fileList.isEmpty())
{
MainWindow::ui->textDumpMessage->append("File is Empty");
return false;
}
MainWindow::ui->textDumpMessage->append("After the QStringList fileList line");
qDebug() << "Load csv";


Notice the new line I have added before return false;.
Now tell us what happens then.

SamT
9th April 2011, 10:17
Hello,

I insert the line as you describe. Here is the result
1. If I select file or files, I still can't get the second text append in QTextEdit. qDebug work as usual. The program still runs.
2. If I don't select the file, I can get the "File is Empty" append in QTextEdit.

Any comment? welcome. :)

Added after 1 54 minutes:

Some new finding...

If the function is finished. The all append text can be shown on the QTextEdit. In other word, if the "QStringList" object (fileList in this case) is destoryed, I can get all update to QTextEdit. Why? does QStringList queues all the message passing to UI? how can I solved this problem. I have to use QStringList.

SamT
9th April 2011, 12:27
I got some new finding on this Keeping_the_GUI_Responsive (http://www.qtcentre.org/wiki/index.php?title=Keeping_the_GUI_Responsive)Maybe I need to use different thread to keep the GUI responsive.