Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Saving UI components to file
Forum Updated to NodeBB v4.3 + New Features

Saving UI components to file

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 584 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.
  • K Offline
    K Offline
    kprog96
    wrote on 26 Jan 2022, 18:14 last edited by
    #1

    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!

    P 1 Reply Last reply 26 Jan 2022, 18:38
    0
    • K kprog96
      26 Jan 2022, 18:14

      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!

      P Offline
      P Offline
      Pl45m4
      wrote on 26 Jan 2022, 18:38 last edited by
      #2

      @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 QSettings and 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


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on 26 Jan 2022, 18:38 last edited by
        #3

        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.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        1
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 26 Jan 2022, 19:24 last edited by
          #4

          Hi,

          One thing you might want to explore is QAbstractFormBuilder.

          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

          1/4

          26 Jan 2022, 18:14

          • Login

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