Unsolved How make a program interface asynchronous with the program logic execution?
-
I have a program which go through
QTableWidget
cells (left&right) and change symbols in them. Execution starts when I press "run" button, but when program executing I can't see intermediate result, only finish result. If I trying resize program interface it freezing. Already trying to avoid this problem with running program logic with concurrent function:int Run() { QFuture<int> future = QtConcurrent::run(this, &Core::run); return 0; } int Core::run () { while (i < 5) { i++; execute(); mainwindow.update(); _table.update(); } return 0; } int Core::execute() { // move right in table _table.item(0, _current++)->background() = Qt::yellow; return 0; }
But this not working. Should I try emit signals for
execute()
function to change colour of table cells, or how you remove freezing of program interface? -
@gyok said in How make a program interface asynchronous with the program logic execution?:
_table.item(0, _current++)->background() = Qt::yellow;
If _table is a QTableWidget I doubt this will ever compile.
-
@gyok the simplest way is to use a QTimer instead a loop. in the timeout slot, process one or a few cells, then exit the slot. that gives Qt the chance to refresh your GUI before you process the next elements.
Regards
-
@Christian-Ehrlicher I add this exemple of code to show the main idea of code