Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How do I set the QThread priority to InherentPriority when it's running?

How do I set the QThread priority to InherentPriority when it's running?

Scheduled Pinned Locked Moved Unsolved General and Desktop
multithreadingqthread
5 Posts 2 Posters 989 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CJha
    wrote on 17 Aug 2022, 07:26 last edited by
    #1

    Hi, I know I can start a QThread myThread with QThread::InherentPriority by using myThread->start(). When the thread is running the function QThread::setPriority(QThread::Priority) can be used to change it's priority, but the documentation says

    The 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 to QThread::InherentPriority? Will I have to quit and restart again, is that the only option?

    J 1 Reply Last reply 17 Aug 2022, 07:36
    0
    • C CJha
      17 Aug 2022, 07:26

      Hi, I know I can start a QThread myThread with QThread::InherentPriority by using myThread->start(). When the thread is running the function QThread::setPriority(QThread::Priority) can be used to change it's priority, but the documentation says

      The 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 to QThread::InherentPriority? Will I have to quit and restart again, is that the only option?

      J Offline
      J Offline
      JonB
      wrote on 17 Aug 2022, 07:36 last edited by
      #2

      @CJha
      Did you try QThread::setPriority(QThread::Priority priority) while the thread is running?

      Also, what platform are you on?

      1 Reply Last reply
      0
      • C Offline
        C Offline
        CJha
        wrote on 17 Aug 2022, 07:47 last edited by
        #3

        @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.

        J 1 Reply Last reply 17 Aug 2022, 07:54
        0
        • C CJha
          17 Aug 2022, 07:47

          @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.

          J Offline
          J Offline
          JonB
          wrote on 17 Aug 2022, 07:54 last edited by
          #4

          @CJha
          You said so far it was QThread::InherentPriority, but transpires you meant InheritPriority.

          Then I can only guess you must fetch/determine the caller's priority and use that to pass the relevant actual value to setPriority().

          1 Reply Last reply
          0
          • C Offline
            C Offline
            CJha
            wrote on 17 Aug 2022, 08:00 last edited by
            #5

            @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!

            1 Reply Last reply
            0

            2/5

            17 Aug 2022, 07:36

            • Login

            • Login or register to search.
            2 out of 5
            • First post
              2/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved