Results 1 to 3 of 3

Thread: Sequence issue in QProgressDialog

  1. #1
    Join Date
    Jan 2017
    Posts
    54
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Sequence issue in QProgressDialog

    I have an app that first displays a splash page with a QPushButton labeled "Start" on it. Nothing happens until user clicks the Start button. Once clicked, the splash page disappears and the data files/modules begin loading -- and there is about a 4 second delay until the Mainwindow appears. I wanted to add either a QprogressBar or a QProgressDialog, and chose the QProgressDialog only because it seems to do what I want without adding a widget somewhere. I don't know if I made the right choice.

    Here is my code for the Start Button:
    Qt Code:
    1. def start(self):
    2. self.accept()
    3.  
    4. self.progress = QProgressDialog()
    5. self.timer = QBasicTimer()
    6. self.progress.setMinimum(0)
    7. self.progress.setMaximum(100)
    8. self.progress.setLabelText("Loading file")
    9. self.progress.setCancelButton(None)
    10. self.progress.setValue(self.step)
    11.  
    12. if self.timer.isActive():
    13. self.timer.stop()
    14. else:
    15. self.timer.start(100, self)
    16.  
    17. def timerEvent(self, event):
    18. if self.step >= 100:
    19. self.timer.stop()
    20. return
    21. self.step = self.step + 10
    22. self.progress.setValue(self.step)
    To copy to clipboard, switch view to plain text mode 

    My problem is the progress bar shows up AFTER the Mainwindow has appeared -- likely because the "self.accept" starts the file loading process and when it finishes, the progress bar appears. I read about "starting another thread" issues, but don't understand and don't know if it's a good idea.

    1. How do I fix?
    2. Should some of the QProgressDialog setup code (minimum, max, set label, etc) be moved to my init section or is it in the right place?
    3. Is the QProgressDialog process set up correctly? ie., with the timer, etc
    4. Currently, my timer is simply based on showing the bar for about 4 seconds. How do I link the timer to the actual time between the Splash page disappearing and the Mainwindow appearing?
    thanks

  2. #2
    Join Date
    Jan 2017
    Posts
    54
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Sequence issue in QProgressDialog

    RESOLVED: I changed the flow of my loading files process and changed to a QProgressBar on the Splash page, and it works fine. Thanks for looking

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,229
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Sequence issue in QProgressDialog

    Was going to reply with that suggestion, but my Python skills aren't strong enough to explain how to implement it.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Run QML files one after another in sequence
    By mvbhavsar in forum Newbie
    Replies: 4
    Last Post: 28th October 2013, 05:00
  2. Sequence of RGBA channels in DDS
    By maxoutlaw in forum Qt Programming
    Replies: 8
    Last Post: 16th September 2012, 22:38
  3. every possible sequence
    By timmu in forum Qt Programming
    Replies: 3
    Last Post: 10th August 2012, 14:36
  4. Load images in a sequence in QML
    By anupama in forum Qt Quick
    Replies: 1
    Last Post: 1st December 2010, 09:24
  5. Frame sequence
    By bmn in forum Qt Programming
    Replies: 7
    Last Post: 22nd May 2008, 22:57

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.