check for non valid object



  • say i have such code:

    ...
    self.mw = QMainWindow()
    self.create_dock_widgets()
    
    ...
    def create_dock_widgets(self):
        # should i check if window is valid object?
        self.mw.addDockWidget...
    

    should i actually do it?



  • @user4592357
    And do what if it isn't? You're only going to raise, and self.mw.addDockWidget will raise anyway if it isn't. Plus self.mw = QMainWindow() would have raised in the first place if it couldn't create a main window.

    Of course you can check everywhere if you wish. But that can be a lot of code. I wouldn't bother here.

    P.S.
    Unless you're doing it for a school project. In which case, goodness knows...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.