Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSettings and xml
Forum Updated to NodeBB v4.3 + New Features

QSettings and xml

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 6 Posters 5.8k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    andreyc
    wrote on last edited by
    #3

    Why do you declare writeXmlFile and readXmlFile again in the lines 8 and 9 in file.cpp above?

    Z 1 Reply Last reply
    1
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #4

      According to "QSettings::registerFormat":http://qt-project.org/doc/qt-5/qsettings.html#registerFormat documentation the writeFunc and readFunc must be either standalone function or static member functions.
      In the "example that you used":http://www.openshots.de/2011/03/qsettings-mit-xml-format/ both functions are standalone functions.

      Move both functions out of the class or make them the static functions of the class.

      1 Reply Last reply
      1
      • A andreyc

        Why do you declare writeXmlFile and readXmlFile again in the lines 8 and 9 in file.cpp above?

        Z Offline
        Z Offline
        zabdielfer
        wrote on last edited by
        #5

        @andreyc

        Hi Andreyc, I have been finding "Qsettings-mit-xml-format", but the link http://www.openshots.de/2011/03/qsettings-mit-xml-format/ is broken, is there some way for i can see this example? thanks

        Z 1 Reply Last reply
        0
        • Z zabdielfer

          @andreyc

          Hi Andreyc, I have been finding "Qsettings-mit-xml-format", but the link http://www.openshots.de/2011/03/qsettings-mit-xml-format/ is broken, is there some way for i can see this example? thanks

          Z Offline
          Z Offline
          zabdielfer
          wrote on last edited by
          #6

          @zabdielfer said in QSettings and xml:

          @andreyc

          Hi Andreyc, I have been searching "Qsettings-mit-xml-format", but the link http://www.openshots.de/2011/03/qsettings-mit-xml-format/ is broken, is there some way for i can see this example? thanks

          1 Reply Last reply
          0
          • K Offline
            K Offline
            karlheinzreichel
            wrote on last edited by karlheinzreichel
            #7

            @zabdielfer as @andreyc sayed. You have to change the methods readXmlFile and writeXmlFile to static members..

            Especially:
            in your header file:
            change

            bool readXmlFile(QIODevice &device, QSettings::SettingsMap &map);
            bool writeXmlFile(QIODevice &device, const QSettings::SettingsMap &map);

            to
            static bool readXmlFile(QIODevice &device, QSettings::SettingsMap &map);
            static bool writeXmlFile(QIODevice &device, const QSettings::SettingsMap &map);

            and remove in the implementation file (QControlPanel constructor) the forward declarations

            bool readXmlFile(QIODevice &device, QSettings::SettingsMap &map);
            bool writeXmlFile(QIODevice &device, const QSettings::SettingsMap &map);

            Z 2 Replies Last reply
            0
            • K karlheinzreichel

              @zabdielfer as @andreyc sayed. You have to change the methods readXmlFile and writeXmlFile to static members..

              Especially:
              in your header file:
              change

              bool readXmlFile(QIODevice &device, QSettings::SettingsMap &map);
              bool writeXmlFile(QIODevice &device, const QSettings::SettingsMap &map);

              to
              static bool readXmlFile(QIODevice &device, QSettings::SettingsMap &map);
              static bool writeXmlFile(QIODevice &device, const QSettings::SettingsMap &map);

              and remove in the implementation file (QControlPanel constructor) the forward declarations

              bool readXmlFile(QIODevice &device, QSettings::SettingsMap &map);
              bool writeXmlFile(QIODevice &device, const QSettings::SettingsMap &map);

              Z Offline
              Z Offline
              zabdielfer
              wrote on last edited by
              #8

              @karlheinzreichel
              thank you, I will try it

              Z 1 Reply Last reply
              0
              • Z zabdielfer

                @karlheinzreichel
                thank you, I will try it

                Z Offline
                Z Offline
                zabdielfer
                wrote on last edited by
                #9
                This post is deleted!
                1 Reply Last reply
                0
                • K karlheinzreichel

                  @zabdielfer as @andreyc sayed. You have to change the methods readXmlFile and writeXmlFile to static members..

                  Especially:
                  in your header file:
                  change

                  bool readXmlFile(QIODevice &device, QSettings::SettingsMap &map);
                  bool writeXmlFile(QIODevice &device, const QSettings::SettingsMap &map);

                  to
                  static bool readXmlFile(QIODevice &device, QSettings::SettingsMap &map);
                  static bool writeXmlFile(QIODevice &device, const QSettings::SettingsMap &map);

                  and remove in the implementation file (QControlPanel constructor) the forward declarations

                  bool readXmlFile(QIODevice &device, QSettings::SettingsMap &map);
                  bool writeXmlFile(QIODevice &device, const QSettings::SettingsMap &map);

                  Z Offline
                  Z Offline
                  zabdielfer
                  wrote on last edited by zabdielfer
                  #10

                  @karlheinzreichel

                  @zabdielfer
                  Hi:
                  how could I get all attributes of a node for example this xml file
                  <Ajustes>
                  <Personalizado>
                  <AjustesECG setting_ecg.V_on="false" setting_ecg.marcapasos="false" setting_ecg.alarm_on_st2="true" />
                  <AjustesRSP setting_rsp.gain="2" setting_rsp.apnea_delay="1" setting_rsp.alarm_on="true" />
                  <AjustesNIBP setting_pni.period="2" setting_pni.alarm_sy_on="true" setting_pni.alarm_di_on="true"
                  <AjustesCO2 setting_cos.apnea_delay="1" setting_cos.compensation="false" setting_cos.alarm_cex_on="true" />
                  <AjustesNO2 setting_nos.alarm_nex_on="false" setting_nos.alarm_nin_on="false" setting_nos.alarm_nex_lvl="1"
                  <AjustesTNM setting_nmt.current="0" setting_nmt.period="0" setting_nmt.type="0" setting_nmt.width="0" />
                  </Personalizado>
                  <Fabrica>
                  <AjustesECG setting_ecg.V_on="false" setting_ecg.marcapasos="false" setting_ecg.alarm_on_st2="true" />
                  <AjustesRSP setting_rsp.gain="2" setting_rsp.apnea_delay="1" setting_rsp.alarm_on="true" />
                  <AjustesNIBP setting_pni.period="2" setting_pni.alarm_sy_on="true" setting_pni.alarm_di_on="true"
                  <AjustesCO2 setting_cos.apnea_delay="1" setting_cos.compensation="false" setting_cos.alarm_cex_on="true" />
                  <AjustesNO2 setting_nos.alarm_nex_on="false" setting_nos.alarm_nin_on="false" setting_nos.alarm_nex_lvl="1"
                  <AjustesTNM setting_nmt.current="0" setting_nmt.period="0" setting_nmt.type="0" setting_nmt.width="0" />
                  </Fabrica>
                  </Ajustes>

                  Taz742T 1 Reply Last reply
                  0
                  • Z zabdielfer

                    @karlheinzreichel

                    @zabdielfer
                    Hi:
                    how could I get all attributes of a node for example this xml file
                    <Ajustes>
                    <Personalizado>
                    <AjustesECG setting_ecg.V_on="false" setting_ecg.marcapasos="false" setting_ecg.alarm_on_st2="true" />
                    <AjustesRSP setting_rsp.gain="2" setting_rsp.apnea_delay="1" setting_rsp.alarm_on="true" />
                    <AjustesNIBP setting_pni.period="2" setting_pni.alarm_sy_on="true" setting_pni.alarm_di_on="true"
                    <AjustesCO2 setting_cos.apnea_delay="1" setting_cos.compensation="false" setting_cos.alarm_cex_on="true" />
                    <AjustesNO2 setting_nos.alarm_nex_on="false" setting_nos.alarm_nin_on="false" setting_nos.alarm_nex_lvl="1"
                    <AjustesTNM setting_nmt.current="0" setting_nmt.period="0" setting_nmt.type="0" setting_nmt.width="0" />
                    </Personalizado>
                    <Fabrica>
                    <AjustesECG setting_ecg.V_on="false" setting_ecg.marcapasos="false" setting_ecg.alarm_on_st2="true" />
                    <AjustesRSP setting_rsp.gain="2" setting_rsp.apnea_delay="1" setting_rsp.alarm_on="true" />
                    <AjustesNIBP setting_pni.period="2" setting_pni.alarm_sy_on="true" setting_pni.alarm_di_on="true"
                    <AjustesCO2 setting_cos.apnea_delay="1" setting_cos.compensation="false" setting_cos.alarm_cex_on="true" />
                    <AjustesNO2 setting_nos.alarm_nex_on="false" setting_nos.alarm_nin_on="false" setting_nos.alarm_nex_lvl="1"
                    <AjustesTNM setting_nmt.current="0" setting_nmt.period="0" setting_nmt.type="0" setting_nmt.width="0" />
                    </Fabrica>
                    </Ajustes>

                    Taz742T Offline
                    Taz742T Offline
                    Taz742
                    wrote on last edited by
                    #11

                    @zabdielfer
                    QXmlStreamReader * rdr = new QXmlStreamReader("path");

                    while (!rdr->atEnd()) {
                    
                        QXmlStreamReader::TokenType token = rdr->readNext();
                    
                        if(token == QXmlStreamReader::StartDocument)
                            continue;
                    
                        if (rdr->name() == "Personalizado") {
                            continue;
                        }
                    
                    
                        if(rdr->name() == "AjustesECG"){
                            qDebug() << rdr->attributes().value("setting_ecg.V_on").toString();
                            qDebug() << rdr->attributes().value("setting_ecg.marcapasos").toString();
                            qDebug() << rdr->attributes().value("setting_ecg.alarm_on_st2").toString();
                        }
                    
                    }
                    

                    Do what you want.

                    Z 1 Reply Last reply
                    1
                    • Taz742T Taz742

                      @zabdielfer
                      QXmlStreamReader * rdr = new QXmlStreamReader("path");

                      while (!rdr->atEnd()) {
                      
                          QXmlStreamReader::TokenType token = rdr->readNext();
                      
                          if(token == QXmlStreamReader::StartDocument)
                              continue;
                      
                          if (rdr->name() == "Personalizado") {
                              continue;
                          }
                      
                      
                          if(rdr->name() == "AjustesECG"){
                              qDebug() << rdr->attributes().value("setting_ecg.V_on").toString();
                              qDebug() << rdr->attributes().value("setting_ecg.marcapasos").toString();
                              qDebug() << rdr->attributes().value("setting_ecg.alarm_on_st2").toString();
                          }
                      
                      }
                      
                      Z Offline
                      Z Offline
                      zabdielfer
                      wrote on last edited by
                      #12

                      @Taz742
                      Thank you for spent time in my topic. :)

                      Taz742T 1 Reply Last reply
                      0
                      • Z zabdielfer

                        @Taz742
                        Thank you for spent time in my topic. :)

                        Taz742T Offline
                        Taz742T Offline
                        Taz742
                        wrote on last edited by
                        #13

                        @zabdielfer
                        Is it helpfull for you?

                        Do what you want.

                        Z 1 Reply Last reply
                        0
                        • Taz742T Taz742

                          @zabdielfer
                          Is it helpfull for you?

                          Z Offline
                          Z Offline
                          zabdielfer
                          wrote on last edited by
                          #14

                          @Taz742
                          yes, thank you

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved