Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Question how to split up a Qt Class into smaller ones
Forum Updated to NodeBB v4.3 + New Features

Question how to split up a Qt Class into smaller ones

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 348 Views 2 Watching
  • 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.
  • LoneSquidL Offline
    LoneSquidL Offline
    LoneSquid
    wrote on last edited by LoneSquid
    #1

    Hello Qt Community!

    I am new. o.o Call me Squid, or how ever you see fit. :) My code is a protocol assistant called ProtocolAssitent.. My first real program that does something useful.. because I like it I am adding more and more into my protocol program and want to clean it to maintain readability. I have ran into some problems and I was wondering how I can improve my coding.

    The main issues I am trying to figure out at the moment are:

    1. How do I split up a Qt Class code into smaller child classes? I am familiar with making child classes but I do not know how I can link the Qt modules into it to make it work.

    2. If I where to have my code being split up, is there a good way to encrypt it so I can run it on a non Python enabled computer? I am able to create .exe files out of .python files, but somehow not every file is converted (as the the program is being split up into multiple files and I only know how to convert a single .py file at the time..

    I have put a tiny example below in English coding style.

    I look forward to any suggestion or advice!

    ~Squid

    """
    The simplified idea of the project I am working on:
    How to get the Q_List_Widget module into a separate file? o.o
    """
    # Initiation UI
    qt_creation_file = "protocolassistent.ui"
    Ui_MainWindow, QtBaseClass = uic.loadUiType(qt_creation_file)
    
    class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
        def __init__(self):
            QtWidgets.QMainWindow.__init__(self)
            Ui_MainWindow.__init__(self)
            self.setupUi(self)
    
        def Q_List_Widget(self):
            self.QListWidget.selectedItems()
            pass
    
    if __name__ == "__main__":
        # Application
        app = QtWidgets.QApplication(sys.argv)
        window = MainWindow()
        window.show()
        sys.exit(app.exec_())
    
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Since you seem to have a big widget that you want to split, the most simple would be to define sections in your UI that could be put in one single "unit". If you take a video editing application, the player is a single unit, the color manager a different one etc.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

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