Important: Please read the Qt Code of Conduct -

how i'm supposed to internally structure my project with Qt?

  • hi!
    idk how i'm supposed to internally structure my program using the Qt framework,in my actual case i have 3 files:
    here i have the basic stuff:

    class MainWindow(QMainWindow):
        def __init__(self):
            self.ui = Ui_MainWindow()
    if __name__ == "__main__":
        app = QApplication(sys.argv)
        window = MainWindow()

    it has all the def´s that gives the gui functionality(i guess?), for example:

    a_button_in_the_ui.clicked.connect(lambda: module_that_does_something(self))

    my problem it's when i do something, where the module should be?, in an for example?

    or maybe all this is nonsense and that's not the standard way to organize stuff?
    that's the .py generated by QDesigner(it has the Ui_MainWindow class)


  • @adrian88888888
    I don't understand what is in/the purpose of your

    a_button_in_the_ui.clicked.connect(lambda: module_that_does_something(self))

    How are you gaining access to a_button_in_the_ui? I would just expect this to be in MainWindow, where you can go self.ui.the_button.clicked.connect(...)?

    Then if you want that clicked slot code to be elsewhere in another module/file, that's fine. Whether it should need a parameter of self is not so clear, why do you need to pass the MainWindow instance off to somewhere? In general, you don't want that other something module to be accessing things back in the main window....

  • @JonB
    i placed the:

    a_button_in_the_ui.clicked.connect(lambda: module_that_does_something(self))

    not inside the MainWindow instance because there are lots of those connections, and there's more stuff in reality, and it's becoming a total mess, that why im in problems with how to organize internally, the instance its getting full of different stuff

    yes, the self part i got no idea yet

    yes i know it doesn't make sense, what should i do? what would you do in my case?

    Thanks btw for helping me

Log in to reply