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

  • Home
  • SEARCH
  • 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 3792840
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:41:06+00:00 2026-05-19T12:41:06+00:00

I have a QMainWindow with a QTabWidget. From the QTabWidget, you can get a

  • 0

I have a QMainWindow with a QTabWidget. From the QTabWidget, you can get a QTabBar and the set the QTabBar’s TabButton as per https://doc.qt.io/archives/qt-4.8/qtabbar.html#setTabButton

So, I’d like to do this to put a throbber (animated gif) next to the text for each tab. This “usually” worked fine, until sometimes a peculiar behavior occured – namely, the animation would freeze and not update. Then, moving your mouse lets the animation update. Clearly there was as issue wit the event processing – if Qt has an event then the animation worked fine, but if not, it paused.

I’ve finally managed to get a reduced testcase for this problem after a days work, and it’s listed below.

Copy the below code into a file, create an ‘images’ subfolder underneath it, and throw in a throbber.gif (say http://upload.wikimedia.org/wikipedia/en/7/78/Netscape_throbber_2.gif ).

Run the program, and notice how the throbber only animates when you move your mouse over the window. Next, change the line EVILNESS=10 to EVILNESS=1 and rerun the program. Notice now how the throbber animates continuously, even without moving your mouse.

Why is this? can I work around it? Am I doing something wrong?

My system:

Windows XP SP3
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)]
PyQt 4.7.4

Thanks for the help / suggestions.

import os, sys
from PyQt4 import QtCore, QtGui

GOODNESS = 10
EVILNESS = 10

class MyWindow(QtGui.QMainWindow):
    def __init__(self, app):
        QtGui.QMainWindow.__init__(self)
        self.app = app
        self.initUI()
        for i in range(GOODNESS):
            self.addTab()
        for i in range(EVILNESS):
            self.animateTabIndex(self.tabMain, i, True)

    def initUI(self):
        self.centralwidget=QtGui.QWidget(self)
        self.tabMain = QtGui.QTabWidget(self.centralwidget)
        self.tabOne = QtGui.QWidget()
        self.tabOne.edit = QtGui.QLineEdit(self.tabOne)
        self.tabOne.edit.setText(QtCore.PYQT_VERSION_STR) #Qt Version
        self.tabOneLayout = QtGui.QVBoxLayout(self.tabOne)
        self.tabOneLayout.addWidget(self.tabOne.edit)
        self.tabMain.addTab(self.tabOne, "First Tab")
        self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget)
        self.verticalLayout.addWidget(self.tabMain)
        self.setCentralWidget(self.centralwidget)

    def addTab(self):
        et = QtGui.QWidget()
        someedit = QtGui.QLineEdit(et)
        somelayout = QtGui.QVBoxLayout(et)
        somelayout.addWidget(someedit)
        self.tabMain.addTab(et, "Extra Tab")

    def animateTabIndex(self, tabWidget, tabIndex, enable):
        print tabIndex
        tabBar = tabWidget.tabBar()
        if enable:
            lbl = QtGui.QLabel(tabWidget)
            movie = QtGui.QMovie(os.path.join(self.app.basedir, "images\\throbber.gif"), parent=lbl)
            movie.setCacheMode(QtGui.QMovie.CacheAll)
            movie.setScaledSize(QtCore.QSize(16, 16))
            lbl.setMovie(movie)
            movie.start()
        else:
            lbl = QtGui.QLabel(tabWidget)
            lbl.setMinimumSize(QtCore.QSize(16, 16))
        tabBar.setTabButton(tabIndex, QtGui.QTabBar.LeftSide, lbl)

class MyApp(QtGui.QApplication):
    basedir = os.path.dirname(__file__)
    def __init__(self, args):
        super(MyApp, self).__init__(args)
        self.mainWindow = MyWindow(self)
    def exec_(self):
        QtCore.pyqtRemoveInputHook() #Needed to allow pdb, etc to work
        ret = super(MyApp, self).exec_()
        return ret

if __name__ == '__main__':
    app = MyApp(sys.argv)
    app.mainWindow.show()
    app.exec_()
  • 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-05-19T12:41:06+00:00Added an answer on May 19, 2026 at 12:41 pm

    Well, this was apparently fixed by PyQt 4.8.2. Guess I should have tried upgrading earlier…

    UPDATE: Specifically this: http:/bugreports.qt-project.org/browse/QTBUG-12721

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a QMainWindow, and want to handle the clicked signal from a smaller
Have you managed to get Aptana Studio debugging to work? I tried following this,
i have a QMainWindow. It has this parameters: this->setWindowFlags(Qt::Tool); this->setFocusPolicy(Qt::StrongFocus); this->setAttribute(Qt::WA_QuitOnClose,true); After showEvent calles
I have a QMainWindow which spawns a few wizards. The QMainWindow has a QFrame
I have a QMainWindow with three widgets inside that are promoted to a class
I have a KMainWindow: //file.h class MainWindow: public KMainWindow { public: MainWindow(QWidget *parent =
Have just started using Google Chrome , and noticed in parts of our site,
Have you ever seen any of there error messages? -- SQL Server 2000 Could
Have you guys had any experiences (positive or negative) by placing your source code/solution
Have just started using Visual Studio Professional's built-in unit testing features, which as I

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.