Unsolved qthread or qtconcurrent.
-
if i have a sort function in ascend order. then plot the data in QT pixelmap and color it base on the value. I have few of these pixelmap window, each run the same sort function but each has different input data, and data update in the ms. to run these concurrently, can this type operation achieve by qthread/movetothread type or using qtconcurrent? or something better.
-
Hi,
Threading is threading, QtConcurrent simply offers you high level tools that avoids you the need to manage threads yourself.
QtConcurrent will likely fill the bill if used correctly.
-
if my sort function is declare in a Qwidget class. do i need to put that function in Qobject or Qthread class before using
Qtconcurrent run?
-
Did you read the documentation about QtConcurrent run ?
-
@SGaist
i read thishttps://doc.qt.io/qt-5.10/qtconcurrentrun.html
it didn't mention if function declare in Qwidget class is fine for qtconcurrent. The reason i ask is because movetothread require Qobject etc.
-
Watch out, you're not allowed to modify GUI elements from other threads.
You should take that kind of thing into account when designing your application.
-
ok thanks, but if my function only doing some background calculation(for example sorting), it just happen to be declare in Qwidget. it should be fine right?
-
It should but it won't be clean.
You should rather properly separate responsibilities. Otherwise you are going to end up with code that will be difficult to maintain and understand.