This is because adding or deleting elements in the config file does not change the value "size __ " automatically.
What do you means for "adding or deleting elements in the config file"?
For me it works.
This code
void EditorWidget::writeSettings()
{
settings.beginGroup ("editor");
settings.beginWriteArray ("contents");
for (int i = 0; i < doc->blockCount (); ++i) {
settings.setArrayIndex (i);
block = doc->findBlockByNumber (i);
settings.setValue ("text", block.text ());
}
settings.endArray ();
settings.endGroup ();
}
void EditorWidget::writeSettings()
{
QSettings settings;
QTextDocument *doc = ui->plainTextEdit->document ();
QTextBlock block;
settings.beginGroup ("editor");
settings.beginWriteArray ("contents");
for (int i = 0; i < doc->blockCount (); ++i) {
settings.setArrayIndex (i);
block = doc->findBlockByNumber (i);
settings.setValue ("text", block.text ());
}
settings.endArray ();
settings.endGroup ();
}
To copy to clipboard, switch view to plain text mode
save the contents of a QPlainTextEdit line by line
Bookmarks