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. How to inheritance from the QPushButton class
Forum Updated to NodeBB v4.3 + New Features

How to inheritance from the QPushButton class

Scheduled Pinned Locked Moved Solved Qt for Python
2 Posts 1 Posters 610 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.
  • M Offline
    M Offline
    Mikeeeeee
    wrote on last edited by Mikeeeeee
    #1

    Hi!
    How to inheritance from the QPushButton class? When I click a button, I need to get a signal from the objectName of the button.
    If I do this, on the click program crashes

    class MyPushButton(QPushButton):
        myClicked = pyqtSignal(str)
        # self.clicked.connect(self.qqq)
    
        def slotForMySignal(self):
            print(self.objectName())
            self.signalNeedUpdate.emit("adg")
    
        def __init__(self, *args):
            QPushButton.__init__(self, *args)
            self.clicked.connect(self.slotForMySignal)
            # self.signalNeedUpdate.emit("adg")
    
    1 Reply Last reply
    0
    • M Offline
      M Offline
      Mikeeeeee
      wrote on last edited by
      #2

      It is work

      class MyPushButton(QPushButton):
          myClicked = pyqtSignal(str)
      
          def slotForMySignal(self):
              self.myClicked.emit(self.objectName())
      
          def __init__(self, *args):
              super().__init__()
              self.clicked.connect(self.slotForMySignal)
      
      1 Reply Last reply
      0

      • Login

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