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

deff(self):
    returnself.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"