Python Forum

Full Version: Gui Button click
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi.

I am making gui application using Qt4, but the whole signals and slots thing seems way too complex, so I suspect it is my coding. But it appears that using the new signals and slots method, I can't work out how to actually connect to a method directly, I seem to always have to go through another method first, otherwise I get a:
bool has no attribute 'whatever'
When I haven't actually coded a single boolean variable in the whole application.

Here is an example:
class MainUiWindow( QtGui.QMainWindow ):
    def __init__(self, parent = None):
        super(MainUiWindow, self).__init__(parent)

    def exampleMethod( self ):
        self.example = aWidget()
        self.example.show()
        self.example.ui_okbtn_act.clicked.connect(self.pointlessMethod)

    def pointlessMethod( self ):
        UiWidget.wantedMethod()

class UiWidget( object ):
    def wantedMethod( self ):
        print('Hello World')
This seems all very good and well untill you have a few things, so now I have 13 methods in my main window class, 5 of these are purely methods that go from the button click to the method I want to use as a result of the button click.

There must be a better more compact way of doing this?
I haven't used Qt in a long while, but when I used it, there was a tutorial on the designer that did a really good job on explaining signal and slots.
I don't know what the name was, or where to find it. But if you can, I think you'll like it.
Something to look for.