Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. check for non valid object

check for non valid object

Scheduled Pinned Locked Moved Solved Language Bindings
2 Posts 2 Posters 732 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    user4592357
    wrote on last edited by
    #1

    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?

    JonBJ 1 Reply Last reply
    0
    • U user4592357

      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?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @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...

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved