How do I set the QThread priority to InherentPriority when it's running?
-
wrote on 17 Aug 2022, 07:26 last edited by
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? -
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?wrote on 17 Aug 2022, 07:36 last edited by@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.wrote on 17 Aug 2022, 07:54 last edited by@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()
.
4/5