Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. disable QRadioButtons by QComboBox choice
Qt 6.11 is out! See what's new in the release blog

disable QRadioButtons by QComboBox choice

Scheduled Pinned Locked Moved Solved General and Desktop
17 Posts 3 Posters 7.4k Views 1 Watching
  • 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #4

    Did you check whether the slot is being called ? That the connection was successful ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    2
    • G gnngnn

      Hello,
      Did someone know how to disable or enable QRadioButtons when QComboBox selection is changed?

      #self.MyQComboBox .clicked.connect(self.MyQComboBoxFunction)

      def MyQComboBoxFunction(self, *args):
      TypeChoice = str(self.MyQComboBox .currentText())
      if TypeChoice == 'LGT': MyQRadioButtons1.setEnabled(false)
      if TypeChoice == 'ANM': MyQRadioButtons2.setEnabled(true)

      Thoses lines aren't working....any ideas?
      by advance, thanks!

      Taz742T Offline
      Taz742T Offline
      Taz742
      wrote on last edited by
      #5
      This post is deleted!
      1 Reply Last reply
      0
      • G gnngnn

        that's true, sorry,

        BatchType = ['LGT','ANM']
        for eachBatchType in BatchType:
        	self.MyQComboBox .addItem(eachBatchType)
        
        self.MyQComboBox.clicked.connect(self.MyQComboBoxFunction)
        
        def MyQComboBoxFunction(self, *args):
        	TypeChoice = str(self.MyQComboBox .currentText())
        	if TypeChoice == 'LGT' :  MyQRadioButtons1.setEnabled(false)
        
        Taz742T Offline
        Taz742T Offline
        Taz742
        wrote on last edited by
        #6

        @SGaist said in disable QRadioButtons by QComboBox choice:

        Did you check whether the slot is being called ? That the connection was successful ?

        If it is so.
        @gnngnn
        https://stackoverflow.com/questions/3965093/pyqt-or-just-qt-how-to-get-qcombobox-to-fire-a-signal-whenever-it-is-set-to-a
        Look up

        1 Reply Last reply
        0
        • G Offline
          G Offline
          gnngnn
          wrote on last edited by
          #7

          Thanks a lot for your answers, so I'd tryed to change this line:

          self.MyQComboBox.clicked.connect(self.MyQComboBoxFunction)
          

          with this:

          self.connect(BatchShotsFoundedTypecmb, QtCore.SIGNAL("currentTextChanged(const QString&)"), self.BatchShotsFoundedTypecmbEnable)
          

          teh result is:
          global name 'BatchShotsFoundedTypecmb' is not defined
          but this line isn' defined it?:

          self.MyQComboBox .addItem(eachBatchType)
          
          Taz742T 1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #8

            Can you share the full code of your python class ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • G gnngnn

              Thanks a lot for your answers, so I'd tryed to change this line:

              self.MyQComboBox.clicked.connect(self.MyQComboBoxFunction)
              

              with this:

              self.connect(BatchShotsFoundedTypecmb, QtCore.SIGNAL("currentTextChanged(const QString&)"), self.BatchShotsFoundedTypecmbEnable)
              

              teh result is:
              global name 'BatchShotsFoundedTypecmb' is not defined
              but this line isn' defined it?:

              self.MyQComboBox .addItem(eachBatchType)
              
              Taz742T Offline
              Taz742T Offline
              Taz742
              wrote on last edited by
              #9

              @gnngnn said in disable QRadioButtons by QComboBox choice:

              self.connect(BatchShotsFoundedTypecmb,

              try
              self.connect(self.BatchShotsFoundedTypecmb, QtCore.SIGNAL("currentTextChanged(const QString&)"), self.BatchShotsFoundedTypecmbEnable)

              1 Reply Last reply
              0
              • G Offline
                G Offline
                gnngnn
                wrote on last edited by
                #10

                here is a more complete version of the UI,

                def getWindow():
                	ptr = mui.MQtUtil.mainWindow()
                	return sip.wrapinstance(long(ptr), QtCore.QObject)
                
                uiFile = os.path.join(os.path.dirname(__file__), 'Gui/ProjectManager.ui')
                form_class, base_class = uic.loadUiType(uiFile)
                
                class ProjectManager(base_class, form_class):
                
                	def __init__(self, parent = getWindow()):
                		super(base_class, self).__init__(parent)
                		self.setupUi(self)
                
                BatchType = ['LGT','ANM']
                for eachBatchType in BatchType:
                	self.MyQComboBox .addItem(eachBatchType)
                
                self.connect(self.BatchShotsFoundedTypecmb, QtCore.SIGNAL("currentTextChanged(const QString&)"), self.BatchShotsFoundedTypecmbEnable)
                self.BatchShotsFoundedTypecmb.currentTextChanged.connect(self.BatchShotsFoundedTypecmbEnable)
                self.show()
                
                def MyQComboBoxFunction(self, *args):
                	TypeChoice = str(self.MyQComboBox .currentText())
                	if TypeChoice == 'LGT' :  MyQRadioButtons1.setEnabled(false)
                

                now the error is: 'QComboBox' object has no attribute 'currentTextChanged'
                i don't understand why?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #11

                  What version of Qt and PyQt are you using ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    gnngnn
                    wrote on last edited by
                    #12

                    Hello SGaist,
                    I use Qt version 4.8.6 and PyQt4... why?

                    1 Reply Last reply
                    1
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #13

                      Because it's the kind of details that are important. For example you are using an outdated version of Qt (latest Qt 4 release is 4.8.7) from a series that has reached EOL.

                      The current Qt version is 5.9.0 with 5.9.1 pointing at the corner.

                      So if you are starting a new project and unless you're locked to that precise version of Qt, you should rather use something a bit more recent.

                      Qt 5 is mostly compatible with some breaks here and there, so again, it's good to know what we deal with. Like also the version of PyQt4 that you are using.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      2
                      • G Offline
                        G Offline
                        gnngnn
                        wrote on last edited by
                        #14

                        Thanks for the explaination :)

                        1 Reply Last reply
                        1
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #15

                          AFAIK, using the new connection style you should have something like:

                          self.BatchShotsFoundedTypecmb.currentIndexChanged['QString'].connect(self.BatchShotsFoundedTypecmbEnable)
                          

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          G 2 Replies Last reply
                          3
                          • SGaistS SGaist

                            AFAIK, using the new connection style you should have something like:

                            self.BatchShotsFoundedTypecmb.currentIndexChanged['QString'].connect(self.BatchShotsFoundedTypecmbEnable)
                            
                            G Offline
                            G Offline
                            gnngnn
                            wrote on last edited by
                            #16
                            This post is deleted!
                            1 Reply Last reply
                            0
                            • SGaistS SGaist

                              AFAIK, using the new connection style you should have something like:

                              self.BatchShotsFoundedTypecmb.currentIndexChanged['QString'].connect(self.BatchShotsFoundedTypecmbEnable)
                              
                              G Offline
                              G Offline
                              gnngnn
                              wrote on last edited by
                              #17

                              @SGaist
                              Thanks you so much, it's working perctly :)

                              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