Saving UI components to file
-
This is a theoretical application that I am trying to prototype.
Let's assume this application already has the capability to let an user create their own assortment of QWidgets in a QGridLayout. What I would also like this application to do is save the QGridLayout and its contents to a file so the user could load that file and their QGridLayout to a window.
Does QT have the power to save Layouts to a file?
If not, can QWidgets be saved to a file?I have successfully been able to use QDataStream to stream my own structs into a file by overloading the << and >> operators. I did attempt the same thing by trying to overload those operators for QGridLayout and QWidget but was unsuccessful in doing so.
Any input would be much appreciated!
Note: The QT version does not matter to me. The main question is if QT (any version) has the capability to perform such actions. Thank you!
-
This is a theoretical application that I am trying to prototype.
Let's assume this application already has the capability to let an user create their own assortment of QWidgets in a QGridLayout. What I would also like this application to do is save the QGridLayout and its contents to a file so the user could load that file and their QGridLayout to a window.
Does QT have the power to save Layouts to a file?
If not, can QWidgets be saved to a file?I have successfully been able to use QDataStream to stream my own structs into a file by overloading the << and >> operators. I did attempt the same thing by trying to overload those operators for QGridLayout and QWidget but was unsuccessful in doing so.
Any input would be much appreciated!
Note: The QT version does not matter to me. The main question is if QT (any version) has the capability to perform such actions. Thank you!
@kprog96 said in Saving UI components to file:
Does QT have the power to save Layouts to a file?
?Not by default. You can save
QSettingsand store properties like geometry and other things.
If you have custom widgets in your layout, you need to develop your own strategy (save a struct with your information to recreate the layout, for example)If not, can QWidgets be saved to a file
You could save the state of your widgets (slider positions, values etc) but not the widget itself
-
You can not save 'the ui' - you can only save the content of the widgets - e.g. a QString for a QLineEdit. But you have to do it by your own.
-
Hi,
One thing you might want to explore is QAbstractFormBuilder.