This may seem like a very strange question but is it possible to generate a Qt Designer form (.ui
) from a Qt object, say something that inherits QWidget
?
My plan is to build a simple dynamic form in code as the user picks what stuff they want e.g fields, type of control and then dump out a .ui
file so that they can tweak the layout if needed after.
The code will then use the QUiLoader
class to reload the ui
file and show the modified or not ui
file.
The Qt-Introspection tool GammaRay can save dialogs from the AUI (Application Under Inspection) to .ui
files in its latest version, IIRC.
Since QWidget inherits from QObject, it gets all of the dynamic property inspection QObject provides. QObjects (and QWidgets) also naturally arrange themselves into trees (see QObject::parent and QObject::children). By following the tree of widgets, and getting the properties of each one, you can generate an xml .ui file containing the basic info about each control.
Working out the signal/slot connections from a pre-established form might be a bit more tricky, since there doesn't seem to be any way to get information on them besides QObject::dumpObjectInfo but for the program you describe in your question it's easy enough to keep track of them some other way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With