Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QCommandLinkButton stops working when I recreate it

QCommandLinkButton stops working when I recreate it

Scheduled Pinned Locked Moved Solved Qt for Python
qt for pythonpythonpyside2
2 Posts 2 Posters 416 Views
  • 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.
  • Black CatB Offline
    Black CatB Offline
    Black Cat
    wrote on last edited by Black Cat
    #1

    Hi guys, basically when I recreate the QCommandLinkButton it stop working (stop printing), someone can identify where is the problem?

    class Ui_MainWindow(object):
        def setupUi(self, MainWindow):
    
            # ....
            # GUI CODE BETWEEN 
            # ....
    
    
            # create the button
            self.del_and_create()
    
    
            # another button to call del_and_create()
            self.btn_new_user2.clicked.connect(self.del_and_create)
    
    
            # if button HOST_1 pressed print "working"
            self.host_1.clicked.connect(lambda: print('working'))
    
        # del and creathe the HOST_1
        def del_and_create(self):
            try:
                self.host_1.deleteLater()
                print('removing the button')
            except:
                pass
    
            # create button
            self.host_1 = QCommandLinkButton(self.scrollAreaWidgetContents_2)
            self.host_1.setObjectName(u"commandLinkButton_1")
            self.host_1.setMinimumSize(QSize(26, 36))
            self.host_1.setMaximumSize(QSize(135, 36))
            self.host_1.setCursor(QCursor(Qt.PointingHandCursor))
            self.host_1.setIconSize(QSize(17, 17))
            self.gridLayout_4.addWidget(self.host_1, 0, 0, 1, 1)
            self.host_1.setText(QCoreApplication.translate("MainWindow", 'hosts', None))
    

    STDOUT:
    405cfb84-4b1f-497c-9438-c3cc22cdc2c5-image.png

    jsulmJ 1 Reply Last reply
    0
    • Black CatB Black Cat

      Hi guys, basically when I recreate the QCommandLinkButton it stop working (stop printing), someone can identify where is the problem?

      class Ui_MainWindow(object):
          def setupUi(self, MainWindow):
      
              # ....
              # GUI CODE BETWEEN 
              # ....
      
      
              # create the button
              self.del_and_create()
      
      
              # another button to call del_and_create()
              self.btn_new_user2.clicked.connect(self.del_and_create)
      
      
              # if button HOST_1 pressed print "working"
              self.host_1.clicked.connect(lambda: print('working'))
      
          # del and creathe the HOST_1
          def del_and_create(self):
              try:
                  self.host_1.deleteLater()
                  print('removing the button')
              except:
                  pass
      
              # create button
              self.host_1 = QCommandLinkButton(self.scrollAreaWidgetContents_2)
              self.host_1.setObjectName(u"commandLinkButton_1")
              self.host_1.setMinimumSize(QSize(26, 36))
              self.host_1.setMaximumSize(QSize(135, 36))
              self.host_1.setCursor(QCursor(Qt.PointingHandCursor))
              self.host_1.setIconSize(QSize(17, 17))
              self.gridLayout_4.addWidget(self.host_1, 0, 0, 1, 1)
              self.host_1.setText(QCoreApplication.translate("MainWindow", 'hosts', None))
      

      STDOUT:
      405cfb84-4b1f-497c-9438-c3cc22cdc2c5-image.png

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Black-Cat You gorgot to connect the clicked signal from the new button...

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved