Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Save whole context



  • Hi evryone !
    I am currently developing a QML application for the industry. this application may have several programs (one at a time). The program change information would be done for the moment via a ComboBox but it will later be a signal sent over the network. I would like to be able to record the whole context (elements, positions, data ... etc) to be able to restore them later. The thing is that elements are created dynamically and I do not know how to save these elements in a file or SQL database. I would like to know if anyone knows what is the best way to do it, or if someone has already done something like that.
    Thank you in advance for your help.



  • @BzhAx hi,
    you can use Settings and QSetings



  • Hi @LeLev , Thank you for your answer
    I watched how to set up these parameters. I managed to do it for simple things like the size of the window, but I can not record TabButtons.
    I tried this way:

    TabBar{
            property int v_nbTool : 1;
            id: id_tabBar
            [...]
            Settings{
                id: id_tabBarSettings
                category: qsTr("TabTool")
                property list<TabButton> listTabButton
            }
    
            TabButton{
                id: idAddTool
                [...]
                }
                onClicked:{
                    var newtool
                    newtool=ToolCreation.createToolObject(idAddTool.x + idAddTool.width* id_tabBar.v_nbTool, "/ToolBar/images/ToolBar/AddTool.png", "Addtool"+ id_tabBar.v_nbTool)
                     id_tabBar.v_nbTool =  id_tabBar.v_nbTool+1
                    id_tabBarSettings.listTabButton.push(newtool)
                }
            }
    

    I don't know if this is the best way to do it..



  • @BzhAx hi,

    @BzhAx said in Save whole context:

    I don't know if this is the best way to do it..

    it works ? do you have errors ?

    You can have your TabButtons in ListModel and use this method :
    https://stackoverflow.com/questions/48730166/how-to-save-and-restore-the-content-of-a-listmodel?rq=1