Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. popup progress dialog
Forum Updated to NodeBB v4.3 + New Features

popup progress dialog

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 2 Posters 457 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.
  • E Offline
    E Offline
    explorer100
    wrote on last edited by
    #1

    Hello,

    I would like to display a popup dialog that shows progress then closes when finished without interacting with the user.
    Is this possible? Thank you.

    J.HilkJ 1 Reply Last reply
    0
    • E explorer100

      Hello,

      I would like to display a popup dialog that shows progress then closes when finished without interacting with the user.
      Is this possible? Thank you.

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @explorer100 yes, Qt provides QProgressDialog for this:

      import sys
      from PyQt6.QtCore import QTimer
      from PyQt6.QtWidgets import QApplication, QProgressDialog
      
      app = QApplication(sys.argv)
      
      # Create the QProgressDialog
      progress_dialog = QProgressDialog("Operation in progress...", "Cancel", 0, 100)
      progress_dialog.setWindowTitle("Progress")
      progress_dialog.setWindowModality(True)
      progress_dialog.setMinimumDuration(0)
      progress_dialog.setAutoReset(True)
      progress_dialog.setAutoClose(True)
      
      # Simulated work process without using sleep
      progress_value = 0
      
      def update_progress():
          global progress_value
          progress_value += 1
      
          # Update the progress bar
          progress_dialog.setValue(progress_value)
      
          # Check if the user clicked the Cancel button
          if progress_dialog.wasCanceled():
              timer.stop()
      
          # Close dialog when it reaches 100
          if progress_value >= 100:
              timer.stop()
              progress_dialog.close()
      
      # Set up a timer to simulate work being done
      timer = QTimer()
      timer.timeout.connect(update_progress)
      timer.start(50)  # Calls the update_progress function every 50ms
      
      sys.exit(app.exec())
      
      

      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      4
      • E Offline
        E Offline
        explorer100
        wrote on last edited by
        #3

        That worked great!! thank you very much.

        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