@sgaist said in Building a "complex" progress widget:
Don't try to steal anything. Use signals and slots to communicate from your secondary threads back to your main thread.
Yes, but as far as I can tell the main thread is "working" (or user has took control over it) as it spawned the secondary threads and is waiting for them to finish processing before moving on.
Edit
Ok so I've now run QMetaObject::invokeMethod(this,={callToLongFunction},Qt::QueuedConnection);
This appear to work, however any loop that was being
#pragma omp parallel for
for (){}
No longer threads... so qt somehow manages to break the omp multithreading ? -- well standalone teste indicates that no... all works there but my app stopped threading... sweet.
Ok I'm a nub, its official! Everything works. It threads & runs job in qt internal event loop thus I don't have any issues. Wow. Ok I need to learn more on qt threading event loop :D I need to fork one for myself and have it process all my work stuff now :- ))
EDIT...
Ok seems like I did a full loop. I went from processing in user thread to processing in qt event loop - fine - but pragma still wont update the widget at the correct time... sigh. Since now we are in event loop, the processing of function is more important than processing of omp thread update signal... I need some kind of priority attached to signal to tell qt that hey... I know u have ur loop but process this signal now.
Right now with Qt::DirectConnection while trying to update val/etc I get this >
######
WARNING: QWidget::repaint: Recursive repaint detected
((null):0, (null))
######
######
WARNING: QBackingStore::endPaint() called with active painter on backingstore paint device
((null):0, (null))
######
And aparently by putting this inside omp seems to "work"...
if (omp_get_thread_num() == 0) {
qApp->processEvents();
}
```... ahhhh multithreading <3