Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved QCommandLinkButton stops working when I recreate it

    Qt for Python
    qt for python python pyside2
    2
    2
    196
    Loading More Posts
    • 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 Cat
      Black Cat last edited by 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

      jsulm 1 Reply Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion @Black Cat last edited by

        @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 Reply Quote 2
        • First post
          Last post