Control view updates
-
Hi, to start off with I am very new to QT so go easy :)
Like hundreds of others out there I am creating a packet capture application. I use a QTableView to display packet information and I add each packet as it's captured to the model calling the insertRows function.
@beginInsertRows(parent, row, row);
//Append packet pointer to list of packet pointers
(*packets).append(packet);
endInsertRows();@The trouble is, when reading in a capture file the application freezes until the file has been completely read at which point the QTableView is suddenly fully udpated with all packets and everything becomes responsive again.
So my question is, what are my options? For starters I believe I need to move the view and the model to a new thread so the rest of the application is responsive, can this be done?
This doesn't solve the view problem though. I'd like packets to be displayed as they are read/captured rather than all at once at the end. Just to note, when I capture packets from a standard session that's not high throughput it works as expected.
Is there a way to add the packets captured/read to the data structure I have but not update the view. Then every second somehow alert the view to update itself. Will this be enough to keep the QTableView responsive so if I were to double click on a packet (row) it would open a more detailed view of the packet while still reading/capturing packets at very high rates?Again sorry for my wording, any help would be appreciated.
-
Well I added a simple timer to control the refreshes, not sure if it's a decent method but it solved my issues.