Skip to content Skip to sidebar Skip to footer

Qt GUI Clickable Qframe Or QWidget Or Groupbox

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 val

Solution 1:

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")

Post a Comment for "Qt GUI Clickable Qframe Or QWidget Or Groupbox"