title: Qt5/PyQt5 best practices
body: <h2>Rewritten to clarify as requested.</h2>
  
  <h2>Disclaimer:</h2>
  
  <p>I am a relative newbie to Qt programming and, to date, I have written only small complexity applications, usually following closely provided examples.</p>
  
  <p>Now I've been asked to (re)write a configuration GUI for an existing product (a cash register, if it matters) based on an embedded Linux which contains a large, possibly expanding, set of "configuration pages". A few examples:</p>
  
  <ul>
  <li>Software update; allowing to selectively update system and/or application.</li>
  <li>Network setup; allowing Wired and WiFi configuration.</li>
  <li>Internal database update (products, prices, ...)</li>
  <li>Maintenance: view internal logs, memory cleanups, ...</li>
  <li>Export: trigger and configure reports on daily/monthly/yearly activity.</li>
  <li>etc.</li>
  </ul>
  
  <p>I started designing the interface in Qt Designer I quickly realized I was about to get a pretty huge mass of spaghetti-code if I simply tried to make a "bigger version" of what I previously had done.</p>
  
  <p>From this stems the original, very general, question:</p>
  
  <p><em>In a complex interface with nested containers (QToolBox, QTabWidget, ...) what is the "approved way" (if any) to partition slots so not to have zillions of them in "MainWindow"?</em></p>
  
  <p><em>Any pointer to "best practices" for non-trivial examples would be welcome.</em></p>
  
  <h2>Status:</h2>
  
  <p>I'm currently in design/prototyping stage and I can change things quite easily; later changes might be less handy, of course.</p>
  
  <p>My current design is quite standard:</p>
  
  <ul>
  <li>a monolithic GUI interface built with Qt Designer with a top-level QToolBox Widget to chose the "page" to edit and individual pages tailored to the specific configuration needs</li>
  <li>import into pyqt5 using the standard paradigm:</li>
  </ul>
  
  <pre class="lang-py prettyprint-override"><code>    class MWindow(QMainWindow):
          def __init__(self):
              super(MWindow, self).__init__()
              uic.loadUi('app.ui', self)
  
          ...
  
      app = QApplication(sys.argv)
      mw = MWindow()
      mw.show()
      sys.exit(app.exec_())
  </code></pre>
  
  <ul>
  <li>have a backend talking with target and providing "commands" to actually perform required actions (I cannot have a proper MVC because 'M' is elsewhere and 'C' is split, partly on configurator, partly on target).</li>
  </ul>
  
  <p>I quickly discovered I can have tens of slots handled for each single "page" if I want to do proper input validation and be "user friendly" (e.g.: to automatically generate netmask/broadcast from edited IP address, not to speak of the ample code duplication between Ethernet configuration and WiFi Configuration). That is not currently required, but I <em>know</em> request will come later on and I want to plan ahead.</p>
  
  <h2>Question:</h2>
  
  <p>In other contexts I would have tried to make all UI-related processing more local; e.g.:</p>
  
  <ul>
  <li>write a class/page to handle IP addresses</li>
  <li>subclass it to add what's required for WiFi.</li>
  <li>build a tabbed widget with a tab for each connection actually available on target, instantiating one of the above classes as needed.</li>
  <li>put the tabbed widget into one of the toolbox pages.</li>
  <li>rinse and repeat.</li>
  </ul>
  
  <p>OTOH some real-life examples (see: <a href="https://github.com/wireshark/wireshark/blob/master/ui/qt/main_window.h#L297-L685" rel="nofollow noreferrer">Wireshark's MainWindow</a>) seem to go in the opposite "everything in a single basket" direction.</p>
  
  <p>Is there any, reasonably consolidated, best-practice recommendation to handle this kind of situation?</p>
  
  <p>More to the point: If I insist in splitting code to have a "divide and conquer" approach, how would that translate into QtDesigner/code relationships? (I definitely don't want to resort to hand-code GUI).</p>