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. Problem with reenabling QPushbutton that launches several expensive processes.
Qt 6.11 is out! See what's new in the release blog

Problem with reenabling QPushbutton that launches several expensive processes.

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 676 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.
  • P Offline
    P Offline
    parameter2
    wrote on last edited by
    #1

    Hello.

    I have a QPushbutton which starts several QtConcurrent::run() operations. These operations take various amount of time to complete, depending on the amount of data to process.

    I'm disabling the QPushbutton at the start of the operations, which I do using the isEnabled property.

    The problem is that I would like to reenable the QPushbutton after all of my QtConcurrent::run() are finished. So I've made a slot to which I connect the finished signal of these operations, but obviously some of the operations are finished earlier than the others and my QPushbutton is enabled too early.

    Just looking for an idea on how to approach that.

    Thanks!

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Since you know the count of run() operations you start, you can count how much are finished.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      P 1 Reply Last reply
      3
      • Christian EhrlicherC Christian Ehrlicher

        Since you know the count of run() operations you start, you can count how much are finished.

        P Offline
        P Offline
        parameter2
        wrote on last edited by
        #3

        @Christian-Ehrlicher said in Problem with reenabling QPushbutton that launches several expensive processes.:

        Since you know the count of run() operations you start, you can count how much are finished.

        Brilliant, thanks! Sorry for such a basic question. I'm dealing with a major brainfart.

        So probably something like this shall do?

        finished_slot() {
        count++;
        
        if(count==num_of_runs){
        	button.setEnabled(true);
        	count=0;
        	}
        }
        
        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          I would say yes.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          1

          • Login

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