QTreeWidget row updates inside QDialog
Hello!
I have a problem regarding udpates to a QTreeWidget inside a QDialog.
The dialog pops up and prompts the user to select a file. This file is read and for each line I want the data to be displayed inside a QTreeWidget. So far so easy.
But, I want each row to be displayed as soon as it is read from the file, but at preset the treeWidget blocks until the whole file is read - only then is all the data displayed.
I'm sure there's an eay fix for this -but I can't for the life of me find it! I've tried various modality options, calls to QCoreApplication::processEvents(), even using threads (slght overkill) - but nothing seems to work.
Any clues anyone?
Re: QTreeWidget row updates inside QDialog
How are you populating the treewidget ? can we see the code ?
Re: QTreeWidget row updates inside QDialog
The treeWidget is populated as ..
Code:
treeWidget->addTopLevelItem(currItem);
for (read line from file) {
item->setText(0, "field 1 from file")
item->setText(1, "field 2 from file")
treeWidget->scrollToItem(item);
}
Re: QTreeWidget row updates inside QDialog
you can create a thread in which you can read data from file line by line and then you can send signal with line which has been read from file to your dialog and then add this line to QTreeWidget.
Re: QTreeWidget row updates inside QDialog
Try calling treewidget->update() in the for loop
Am not sure though if it wil work