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 7442241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:08:44+00:00 2026-05-29T11:08:44+00:00

I have several QComboBoxes in my PyQt4/Python3 GUI and they are filled with some

  • 0

I have several QComboBoxes in my PyQt4/Python3 GUI and they are filled with some entries from a database during the initialisation. Initial CurrentIndex is set to 0. There is also a tick box which changes the language of the items in my combo boxes. To preserve current user selection I backup index of the current item and setCurrentIndex to this number after I fill in ComboBox with translated items. All those actions emit currentIndexChanged signal.

Based on the items selected in QComboBoxes some plot is displayed. The idea is to redraw the plot online – as soon as the user changes any of ComboBox current item. And here I have a problem since if I redraw the plot every time signal currentIndexChanged is emited, I redraw it also several times during initialization and if the translation tick box selection was changed.

What is the best way to separate these cases? In principle I need to separate programmical current Index Change from the user, and update the plot only in the later case (during GUI initialisation I can programically call update plot function once). Should I write/rewrite any signal? If so, I never did that before and would welcome any hint or a good example. Use another signal? Or maybe there is a way to temporary block all signals?

  • 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-29T11:08:45+00:00Added an answer on May 29, 2026 at 11:08 am

    There are a few different things you can try.

    Firstly, you can make sure you do all your initialization before you connect up the signals.

    Secondly, you could use the activated signal, which is only sent whenever the user selects an item. (But note that, unlike currentIndexChanged, this signal is sent even if the index hasn’t changed).

    Thirdly, you could use blockSignals to temporarily stop any signals being sent while the current index is being changed programmatically.

    Here’s a script that demonstrates these possibilities:

    from PyQt4 import QtGui, QtCore
    
    class Window(QtGui.QWidget):
        def __init__(self):
            QtGui.QWidget.__init__(self)
            layout = QtGui.QVBoxLayout(self)
            self.combo = QtGui.QComboBox()
            self.combo.setEditable(True)
            self.combo.addItems('One Two Three Four Five'.split())
            self.buttonOne = QtGui.QPushButton('Change (Default)', self)
            self.buttonOne.clicked.connect(self.handleButtonOne)
            self.buttonTwo = QtGui.QPushButton('Change (Blocked)', self)
            self.buttonTwo.clicked.connect(self.handleButtonTwo)
            layout.addWidget(self.combo)
            layout.addWidget(self.buttonOne)
            layout.addWidget(self.buttonTwo)
            self.changeIndex()
            self.combo.activated['QString'].connect(self.handleActivated)
            self.combo.currentIndexChanged['QString'].connect(self.handleChanged)
            self.changeIndex()
    
        def handleButtonOne(self):
            self.changeIndex()
    
        def handleButtonTwo(self):
            self.combo.blockSignals(True)
            self.changeIndex()
            self.combo.blockSignals(False)
    
        def changeIndex(self):
            index = self.combo.currentIndex()
            if index < self.combo.count() - 1:
                self.combo.setCurrentIndex(index + 1)
            else:
                self.combo.setCurrentIndex(0)
    
        def handleActivated(self, text):
            print('handleActivated: %s' % text)
    
        def handleChanged(self, text):
            print('handleChanged: %s' % text)
    
    if __name__ == '__main__':
    
        import sys
        app = QtGui.QApplication(sys.argv)
        window = Window()
        window.show()
        sys.exit(app.exec_())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several problems relating to NSPredicates, here are they; 1.) My code is
I have several div's that have their html modified during the life of the
We have a GUI of several frames that build their contents dynamically. Each frame
We have several Visual Studio projects, and we would like to: enable/disable some defines
I have several applications that I wish to deploy using rpm. Some of the
I have several CONST's defined on some classes, and want to get a list
I have several cron jobs and I'd like to perform some calculations on them,
I have several GUI forms in my java application. All of forms have texts.
I have several sortable lists connected together, so I can drag one item from
I have several phylogenetic trees imported into R from Newick format. I am using

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.