Unsolved How do I set the QThread priority to InherentPriority when it's running?
-
Hi, I know I can start a
QThread myThread
withQThread::InherentPriority
by usingmyThread->start()
. When the thread is running the functionQThread::setPriority(QThread::Priority)
can be used to change it's priority, but the documentation saysThe priority argument can be any value in the QThread::Priority enum except for InheritPriority.
So, if I start my thread such as
myThread->start(QThread::HighPriority)
then how can I want to switch back toQThread::InherentPriority
? Will I have to quit and restart again, is that the only option? -
@CJha
Did you try QThread::setPriority(QThread::Priority priority) while the thread is running?Also, what platform are you on?
-
@JonB I tried it, it says
QThread::setPriority: Argument cannot be InheritPriority
For any other priority, it works fine (at least no error or warning).
I am using Windows 11. -
@CJha
You said so far it wasQThread::InherentPriority
, but transpires you meantInheritPriority
.Then I can only guess you must fetch/determine the caller's priority and use that to pass the relevant actual value to
setPriority()
. -
@JonB It is
InheritPriority
It was a mistake from my side. Yes, I think you are right, I will have to go to the caller for that. Thanks!