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 to set Application Execution Priority to High.
Forum Updated to NodeBB v4.3 + New Features

How to set Application Execution Priority to High.

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 2.3k 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.
  • R Offline
    R Offline
    Rajesh Panati
    wrote on 23 May 2020, 06:12 last edited by
    #1

    Hi, I need to set my application execution priority to high, as we do in Task Manager (Screenshot attached below for reference) is it possible to set app execution priority to high in the code or settings? Kindly help me.

    Screenshot (29).png

    J 1 Reply Last reply 23 May 2020, 06:23
    0
    • R Rajesh Panati
      23 May 2020, 06:12

      Hi, I need to set my application execution priority to high, as we do in Task Manager (Screenshot attached below for reference) is it possible to set app execution priority to high in the code or settings? Kindly help me.

      Screenshot (29).png

      J Online
      J Online
      JonB
      wrote on 23 May 2020, 06:23 last edited by JonB
      #2

      @Rajesh-Panati
      This is outside the scope of Qt, and is also completely OS-dependent. (You should not be allowed to raise the priority of a program within itself, and Linux at least won't let you do it.) Windows Task Manager is presumably a privileged/elevated running program, which allows it to alter other process's priorities. Goodness knows whether raising a process's priority has any real, noticeable effect under Windows.

      You may be able to achieve something under Windows by looking at QThread::currentThread()->setPriority(), but I'm not sure that does anything for the application as a whole. You could also look at SetPriorityClass Win32 function; again, I don't know whether you can raise your own, already-running priority.

      R 1 Reply Last reply 23 May 2020, 06:34
      1
      • J JonB
        23 May 2020, 06:23

        @Rajesh-Panati
        This is outside the scope of Qt, and is also completely OS-dependent. (You should not be allowed to raise the priority of a program within itself, and Linux at least won't let you do it.) Windows Task Manager is presumably a privileged/elevated running program, which allows it to alter other process's priorities. Goodness knows whether raising a process's priority has any real, noticeable effect under Windows.

        You may be able to achieve something under Windows by looking at QThread::currentThread()->setPriority(), but I'm not sure that does anything for the application as a whole. You could also look at SetPriorityClass Win32 function; again, I don't know whether you can raise your own, already-running priority.

        R Offline
        R Offline
        Rajesh Panati
        wrote on 23 May 2020, 06:34 last edited by
        #3

        Hi @JonB Ok. Thank you for your quick response. Wanted know if this can be achieved within QT.

        Regards,

        Rajesh P

        1 Reply Last reply
        0
        • B Offline
          B Offline
          Bonnie
          wrote on 23 May 2020, 06:57 last edited by
          #4

          Setting priority of the current process can be done in Window's API

          SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
          

          But not in Qt, Qt only provides setting priority of QThread.

          J R 2 Replies Last reply 23 May 2020, 08:38
          1
          • B Bonnie
            23 May 2020, 06:57

            Setting priority of the current process can be done in Window's API

            SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
            

            But not in Qt, Qt only provides setting priority of QThread.

            J Online
            J Online
            JonB
            wrote on 23 May 2020, 08:38 last edited by
            #5

            @Bonnie
            Which is what I suggested: so Windows does allow a process to boost its own priority, without any non-default/elevated privileges? In which case, it wouldn't surprise me if loads of applications might do this, everyone thinks their program is more important than anyone else's! ;-)

            B 1 Reply Last reply 23 May 2020, 09:16
            0
            • J JonB
              23 May 2020, 08:38

              @Bonnie
              Which is what I suggested: so Windows does allow a process to boost its own priority, without any non-default/elevated privileges? In which case, it wouldn't surprise me if loads of applications might do this, everyone thinks their program is more important than anyone else's! ;-)

              B Offline
              B Offline
              Bonnie
              wrote on 23 May 2020, 09:16 last edited by Bonnie
              #6

              @JonB Hmm..I'm not sure how does Windows handle this priority thing.
              But if you have the above code executed in your app, it does show as "High Priority" in Task Manager.

              1 Reply Last reply
              2
              • B Bonnie
                23 May 2020, 06:57

                Setting priority of the current process can be done in Window's API

                SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
                

                But not in Qt, Qt only provides setting priority of QThread.

                R Offline
                R Offline
                Rajesh Panati
                wrote on 25 May 2020, 03:35 last edited by
                #7

                Hi, @Bonnie Thank you for the response. will try it.

                1 Reply Last reply
                0

                1/7

                23 May 2020, 06:12

                • Login

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