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. Is QSettings usable with large files?
Forum Updated to NodeBB v4.3 + New Features

Is QSettings usable with large files?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 400 Views
  • 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.
  • M Offline
    M Offline
    Max Fedotov
    wrote on last edited by
    #1

    I store my object structure in the ini file. Recently I created quite a lot of new objects and saved them. All was ok, but my ini file grew to 630 KB. But now loading object structure from that file takes a lot of time (almost a minute). Is QSettings usable with such large inis?
    Here's example code how I load objects:

    for(auto & it: objs)
    {
    	m_pConnection->beginGroup(objectSectionName(it));
    	Signal* pSig=dynamic_cast<Signal*>(it);
    	pSig->setType(dynamic_cast<SignalType*>(m_pFactory->getObject(m_pConnection->value("SignalTypeGuid").toInt())));
    	pSig->setCheckpoint(dynamic_cast<Checkpoint*>(m_pFactory->getObject(m_pConnection->value("CheckpointGuid").toInt())));
    	pSig->m_bAnalog=m_pConnection->value("Analog").toBool();
    	pSig->m_bHardware=m_pConnection->value("Hardware").toBool();
    	int v=QMetaEnum::fromType<ARMSStatus>().keyToValue(m_pConnection->value("StatusOnSet").toString().toLatin1().data(), &ok);
    	pSig->m_eStatusOnSet=(ok ? (ARMSStatus)v : ARMSStatus::Normal);
    	pSig->m_iPriorityOnSet=m_pConnection->value("PriorityOnSet").toInt();
    	pSig->m_sMessageOnSet=m_pConnection->value("MessageOnSet").toString();
    	v=QMetaEnum::fromType<ARMSStatus>().keyToValue(m_pConnection->value("StatusOnClear").toString().toLatin1().data(), &ok);
    	pSig->m_eStatusOnClear=(ok ? (ARMSStatus)v : ARMSStatus::Normal);
    	pSig->m_iPriorityOnClear=m_pConnection->value("PriorityOnClear").toInt();
    	pSig->m_sMessageOnClear=m_pConnection->value("MessageOnClear").toString();
    	pSig->m_iInputNumber=m_pConnection->value("InputNumber").toInt();
    	m_pConnection->beginGroup("CurrentData");
    	pSig->m_cLastDateTime=QDateTime::fromString(m_pConnection->value("DateTime").toString(), "yyyy-MM-dd hh:mm:ss.zzz");
    	pSig->m_dLastAnalogValue=m_pConnection->value("AnalogValue").toDouble();
    	pSig->m_bLastBitValue=m_pConnection->value("BitValue").toBool();
    	pSig->m_bLastBitChanged=m_pConnection->value("BitChanged").toBool();
    	pSig->m_cLastBitChangedDateTime=QDateTime::fromString(m_pConnection->value("BitChangedDateTime").toString(), "yyyy-MM-dd hh:mm:ss.zzz");
    	pSig->m_cLastArchiveDateTime=QDateTime::fromString(m_pConnection->value("ArchiveDateTime").toString(), "yyyy-MM-dd hh:mm:ss.zzz");
    	pSig->m_dLastArchiveAnalogValue=m_pConnection->value("ArchiveAnalogValue").toDouble();
    	pSig->m_bLastArchiveBitValue=m_pConnection->value("ArchiveBitValue").toBool();
    	m_pConnection->endGroup(); //CurrentData
    	m_pConnection->endGroup(); //Object
    	it->m_bActivated=true;
    }
    
    1 Reply Last reply
    0
    • M Offline
      M Offline
      Max Fedotov
      wrote on last edited by
      #5

      Turned out QSettings was not the cause of the problem. I used QMultiMap::keys() instead of uniqueKeys() creating a lot of extra useless iterations.

      1 Reply Last reply
      1
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @Max-Fedotov said in Is QSettings usable with large files?:

        file takes a lot of time (almost a minute). Is QSettings usable with such large inis?

        Doesn't this already answer your question?
        I would use a small sqlite db or (de)serialize the data structure with QDataStream instead.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        1
        • M Offline
          M Offline
          Max Fedotov
          wrote on last edited by
          #3

          Thanks. I still need to be able to edit config file manually from text editor. Maybe I'll make caching ini parser, that loads the entire file once.

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #4

            @Max-Fedotov said in Is QSettings usable with large files?:

            I still need to be able to edit config file manually from text editor

            This just cries for problems but it's not mine :)

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            0
            • M Offline
              M Offline
              Max Fedotov
              wrote on last edited by
              #5

              Turned out QSettings was not the cause of the problem. I used QMultiMap::keys() instead of uniqueKeys() creating a lot of extra useless iterations.

              1 Reply Last reply
              1

              • Login

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