Na ovoj stranici

Utils::PersistentSettingsReader Class

class Utils::PersistentSettingsReader

Klasa PersistentSettingsReader čita skup postavki ( QVariantMap ) proizvoljnih, ugniježđenih struktura podataka iz XML datoteke. Više...

Header: #include <PersistentSettingsReader>

Detaljan opis

Podržava sve string-serializable jednostavne tipove te QVariantList i QVariantMap. Primjer:

<qtcreator>
    <data>
        <variable>ProjectExplorer.Project.ActiveTarget</variable>
        <value type="int">0</value>
    </data>
    <data>
        <variable>ProjectExplorer.Project.EditorSettings</variable>
        <valuemap type="QVariantMap">
            <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
        </valuemap>
    </data>

Pri parsiranju strukture za svaki element <data> koristi se parse stack od ParseValueStackEntry. ParseValueStackEntry je varijanta/unija od:

  • jednostavna vrijednost
  • mapu
  • popis

Možete registrirati funkcije za string-serijalizaciju prilagođenih tipova registriranjem u Qt Meta sustav tipova. Primjer:

QMetaType::registerConverter(&MyCustomType::toString);
QMetaType::registerConverter<QString, MyCustomType>(&myCustomTypeFromString);

Pri ulasku u element s vrijednošću ( <value> / <valuelist>, <valuemap> ) odgovarajuća se stavka gura na gomilu. Pri izlasku iz elementa, vrijednost QVariant-stavke uklanja se s gomile i dodaje se u donju stavku gomile (dodaje se na popis ili se ubacuje u mapu). Prva stavka gomile je vrijednost elementa <data>.

Vidi također Utils::PersistentSettingsWriter.

Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.