How to save settings of a window that contains widgets with same object name?
-
I have a QMainWindow where I create new instances of a specific
.uicreated on Qt Designer, each new instance the widgets contains the same object name, example:// test.h #pragma once #include "stdafx.h" QT_BEGIN_NAMESPACE namespace Ui { class Form; }; QT_END_NAMESPACE class Test : public QWidget { Q_OBJECT public: Ui::Form* ui; Test(QWidget* parent = nullptr) : QWidget(parent), ui(new Ui::Form()) { ui->setupUi(this); } }; // mainwindow Test test = new Test(...); // <- Test test_2 = new Test(...); // <- all widgets from both `Test` contains same object nameThere's another way to differentiate the widgets other than using their object names when saving their values to a
settings.inifile?If no, I'm looking for suggestions in how else I could achieve this, I mean, maybe appending a special character before each widget
objectName? -
I have a QMainWindow where I create new instances of a specific
.uicreated on Qt Designer, each new instance the widgets contains the same object name, example:// test.h #pragma once #include "stdafx.h" QT_BEGIN_NAMESPACE namespace Ui { class Form; }; QT_END_NAMESPACE class Test : public QWidget { Q_OBJECT public: Ui::Form* ui; Test(QWidget* parent = nullptr) : QWidget(parent), ui(new Ui::Form()) { ui->setupUi(this); } }; // mainwindow Test test = new Test(...); // <- Test test_2 = new Test(...); // <- all widgets from both `Test` contains same object nameThere's another way to differentiate the widgets other than using their object names when saving their values to a
settings.inifile?If no, I'm looking for suggestions in how else I could achieve this, I mean, maybe appending a special character before each widget
objectName? -
@Ylvy
Exactly that, you would have to e.g. append a sequence number or a number based on whichnew Test()you are in to each widget'sobjectName()if you wish to identify it uniquely across sessions.