Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8373705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:44:48+00:00 2026-06-09T14:44:48+00:00

I’m wanting to customize the look of a QProgressBar with a stylesheet. I’d like

  • 0

I’m wanting to customize the look of a QProgressBar with a stylesheet. I’d like to give it that animated, ‘indeterminate’ look. So I made an animated GIF to stick in the background of the QProgressBar::chunk.

It shows up fine, but the image is static, with no animation. Any suggestions or workarounds?

I’m running PyQt 4.9.4 on OS X 10.8.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T14:44:50+00:00Added an answer on June 9, 2026 at 2:44 pm

    So, this is a slightly more complex problem that you’re facing.

    The QProgressBar relies on information from a loop or some determined amount to represent the percentage complete. When you set the value through your code, Qt will set the value of the progress bar, redraw it and thus show the updated value. This actually takes a few milliseconds of processing within your loop. If you didn’t do this, then Qt’s optimization wouldn’t ever redraw. This is sychronous.

    The “indeterminate” look that you are going for (like an AJAX gif spinner or bar) is used on the web because the process actually moved off the client-side and is being processed on a server and is waiting for the response. The client’s process is not blocked at all, so it is free to update the interface with the movie.

    You can achieve the look you’re going for by using QMovie in a QLabel:

    movie = QMovie()
    movie.setFileName('/path/to/ajax_loader.gif')
    movie.start()
    
    label = QLabel(parent)
    label.setMovie(movie)
    

    This will make your indeterminate spinner. However, it will only play as long as the event loop is processing events. Once you start your actual worker process, it blocks the event loop so your movie will start playing.

    You’ll need to actually “pump” the events to the player in your loop to get it to update. You can do this by:

    app = QApplication.instance()
    
    # show my label
    label.show()
    
    for obj in objs:
        # process stuff on my obj
        app.processEvents()
    
    # hide the label
    label.hide()
    

    Of course, depending on how long each individual action you’re doing in your loop takes, your spinner/loader movie will be “stuck” until the events are processed again.

    Really, the best way to achieve the look you are going for is with a threaded application. You can use QThread to perform all of your actions and display the loader image to the user while it is processing. This is more similar to the way ajax works – the main Qt Event Loop will continue running as your worker thread processes everything – in an unknown amount of time. This is asynchronous.

    Something like:

    class MyThread(QThread):
        def run( self ):
           # perform some actions
           ...
    
    class MyDialog(QDialog):
        def __init__( self, parent ):
            # initialize the dialog
            ...
            self._thread = MyThread(self)
            self._thread.finished.connect(self.refreshResults)
    
            self.refresh()
    
        def refresh( self ):
            # show the ajax spinner
            self._ajaxLabel.show()
    
            # start the thread and wait for the results
            self._thread.start()
    
        def refreshResults( self ):
            # hide the ajax spinner
            self._ajaxLabel.hide()
    
            # process the thread results
            ...
    

    I have a loader widget that I use whenever I do stuff like this in my GUI library. If you want to see the code for it/use it, its at http://dev.projexsoftware.com/projects/projexui and the class is XLoaderWidget (projexui.widgets.xloaderwidget)

    The setup is same as above, but would just be:

    from projexui.widgets.xloaderwidget import XLoaderWidget
    
    class MyThread(QThread):
        def run( self ):
           # perform some actions
           ...
    
    class MyDialog(QDialog):
        def __init__( self, parent ):
            # initialize the dialog
            ...
            self._thread = MyThread(self)
            self._thread.finished.connect(self.refreshResults)
    
            self.refresh()
    
        def refresh( self ):
            # show the ajax spinner
            XLoaderWidget.start(self)
    
            # start the thread and wait for the results
            self._thread.start()
    
        def refreshResults( self ):
            # hide the ajax spinner
            XLoaderWidget.stop(self)
    
            # process the thread results
            ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.