1

Topic: How to write universal function of saving of values ?

There are some dialog boxes on which are outlined . It would be desirable to write universal function on saving of values  between user sessions.  a dialog box and operation with object QSettings of questions does not cause search. Not clearly how to receive VALUES for saving. After all at me text  , and it is necessary to receive their values.
Now I receive values so ():

Data = ui-> NameWidget-> text ();

How to write universal function?

2

Re: How to write universal function of saving of values ?

AlekseySQL;
I will write on Monday, as.
At us it is made

3

Re: How to write universal function of saving of values ?

As it is approximately made at us:
The object of type "property list" (Properties) which as a matter of fact is the concrete list of values on basis QMap <QString, QVariant> is implemented
The object can through MetaObject be anchored ( connect ) to  with put down through DynamicProperty a property name, and to listen to certain signals which are sent  at change of their value. Value is sent in a signal in the form of QVariant. Signals are sent as propertyChanged (), approximately as is described here
on the form all own, are trained to send these signals.
Approximately so.
Probably, it is possible to involve  from QML, they like as it is all should be able already.

4

Re: How to write universal function of saving of values ?

MasterZiv wrote:

approximately as it is described here

it is direct native , building)) borland-specificity penetrates into world Qt, it appears, with great strides))

5

Re: How to write universal function of saving of values ?

AlekseySQL wrote:

There are some dialog boxes on which are outlined . It would be desirable to write universal function on saving of values  between user sessions.
....
How to write universal function?

There is such thing " serialization ". Here it very much helps you.
Make for all dialogues which it is necessary to save pair of functions in the spirit of save/load and in them save and  all that it is necessary to save and recover.
Simply make an additional class:

class serializable {
QString save () = 0;
bool load (QString) = 0;
};

Add this class as the additional ancestor in those dialogues where it is necessary. And in procedure of global saving of dialogues - you bypass dialogues and if they offsprings of the given class - cause appropriate functions.

6

Re: How to write universal function of saving of values ?

egorych wrote:

it is passed...
It is direct native , building)) borland-specificity penetrates into world Qt, it appears, with great strides))

I think, you strongly are mistaken.
There is not present any  .
There there is a programming based on the description, on meta data, i.e. declarative.
And made normally, and openly.
So essentially differs from Borland.

7

Re: How to write universal function of saving of values ?

MasterZiv wrote:

So essentially differs from Borland.

that not. Here, find 8 differences:

// in building
//properties
public:
__ property AnsiString author = {read = getAuthor, write = setAuthor};
//access methods
private:
AnsiString getAuthor () const {return _author;}
void setAuthor (const AnsiString &value) {_author = value;}
// in Qt
Q_PROPERTY (QString author READ author WRITE setAuthor NOTIFY authorChanged)
public:
void setAuthor (const QString &a) {
if (a! = m_author) {
m_author = a;
emit authorChanged ();
}
}
QString author () const {return m_author;}

Simply  built in it the compiler, and  - in .
Well and signals, of course, building is not able to throw.
It still __ closure to implement as at , ))

8

Re: How to write universal function of saving of values ?

White Owl wrote:

There is such thing " serialization ". Here it very much helps you.
Make for all dialogues which it is necessary to save pair of functions in the spirit of save/load and in them save and  all that it is necessary to save and recover.
Simply make an additional class:

class serializable {
QString save () = 0;
bool load (QString) = 0;
};

Add this class as the additional ancestor in those dialogues where it is necessary. And in procedure of global saving of dialogues - you bypass dialogues and if they offsprings of the given class - cause appropriate functions.

So all is possible normal procedure in dialogue to save smile It would be desirable to refuse a reality of separate dialogue that the global method itself transversed all , received their VALUES (here it is impossible to me!) also saved.

9

Re: How to write universal function of saving of values ?

MasterZiv wrote:

As it is approximately made at us:
The object of type "property list" (Properties) which as a matter of fact is the concrete list of values on basis QMap <QString, QVariant> is implemented
The object can through MetaObject be anchored ( connect ) to  with put down through DynamicProperty a property name, and to listen to certain signals which are sent  at change of their value. Value is sent in a signal in the form of QVariant. Signals are sent as propertyChanged (), approximately as is described here
on the form all own, are trained to send these signals.
Approximately so.
Probably, it is possible to involve  from QML, they like as it is all should be able.

Thanks, but are bulky it turns out (it is necessary  to anchor everyone to object).

10

Re: How to write universal function of saving of values ?

egorych wrote:

it still __ closure to implement as at , ))

Better to do nothing as at Borlanda.
Because Borland at last died.

11

Re: How to write universal function of saving of values ?

AlekseySQL wrote:

Thanks, but are bulky it turns out (it is necessary  to anchor everyone to object).

To what object?

12

Re: How to write universal function of saving of values ?

MasterZiv wrote:

To what object?

wrote:

the object of type "property list" (Properties) which as a matter of fact is the concrete list of values on the basis of QMap <QString, QVariant> Is implemented
The object can through MetaObject be anchored...

13

Re: How to write universal function of saving of values ?

AlekseySQL wrote:

it is passed...
it is passed...

So there in that also put that it becomes one function, which on names to properties  corresponding to them ...