Question how to split up a Qt Class into smaller ones
-
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:
-
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.
-
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_())
-
-
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.