Qt GUI clickable Qframe or QWidget or Groupbox

前端 未结 1 1000
春和景丽
春和景丽 2021-01-28 20:54

I have a problem with my code :/ My program needs to click a QFrame, QWidget or QGroupBox. At the moment I use mouseReleaseEvent but it only works when my function doesn\'t have

相关标签:
1条回答
  • 2021-01-28 21:32

    Create a function that does not take arguments

    You have to assign a function to mousePressEvent and self.testc("ssssss") does (probably) not return a function.

    What you can do is to create another function

    def f(self):
        return self.testc("ssssss")
    

    and assign

    self.frame.mousePressEvent = self.f
    

    For such one-liners it is often preferred to create lambda

    self.frame.mousePressEvent = lambda: self.tests("ssssss")
    
    0 讨论(0)
提交回复
热议问题