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. QLineedit adding extra \ from text()
QtWS25 Last Chance

QLineedit adding extra \ from text()

Scheduled Pinned Locked Moved Solved General and Desktop
qlineeditqsettingsutf-8
3 Posts 3 Posters 217 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.
  • S Offline
    S Offline
    sayan275
    wrote on 24 Jun 2024, 17:29 last edited by sayan275
    #1

    Am entering a string in QLineEdit as SIM VFB ALL.DataProcCycle.EmGenObjectList.aObject[.].Kinematic.fDistX*.
    Then am reading the text and creating ini file with qsettings.
    code is as below

    QSettings* settings = new QSettings(m_taskPath + SignalSettingsData::SIGNALSETTINGS_FILENAME, QSettings::IniFormat);
    settings->beginGroup(m_RadarSignalEditorUI->projectNameLbl->text());
    for(QLineEdit* lineedit : m_RadarSignalEditorUI->scrollAreaWidgetContents->findChildren<QLineEdit*>())
    {
        if(lineedit && !lineedit->text().isEmpty())
         {
              QString objName = lineedit->objectName();
              objName = objName.remove("lineEdit_");
              QString textentered = lineedit->text();
              qInfo()<<__FUNCTION__<<textentered;
    //            textemtered = lineedit->text().toUtf8().constData();
    //            qInfo()<<__FUNCTION__<<textemtered;
              settings->setValue(objName, textentered);
         }
    }
    settings->endGroup();
    settings->sync();
    

    But double backslashes are being added. one extra \ .
    In UI its ok, but in debug statements also \ and in the ini file also.
    c479eb8a-f28b-4033-bead-b58f554fcf90-image.png

    e61eb4f7-c56d-499f-894b-f9e8d6a68bc1-image.png

    same in INI file also
    c135ddd5-ac1b-4dd3-990b-f1a099ac6d3a-image.png

    Forward slash can't be used. these are signal urls

    How to get proper string from the lineedit->text() in the ini file like below
    f907e41f-086b-4753-9f8e-ba986dfb73e5-image.png

    C C 2 Replies Last reply 24 Jun 2024, 17:49
    0
    • S sayan275
      24 Jun 2024, 17:29

      Am entering a string in QLineEdit as SIM VFB ALL.DataProcCycle.EmGenObjectList.aObject[.].Kinematic.fDistX*.
      Then am reading the text and creating ini file with qsettings.
      code is as below

      QSettings* settings = new QSettings(m_taskPath + SignalSettingsData::SIGNALSETTINGS_FILENAME, QSettings::IniFormat);
      settings->beginGroup(m_RadarSignalEditorUI->projectNameLbl->text());
      for(QLineEdit* lineedit : m_RadarSignalEditorUI->scrollAreaWidgetContents->findChildren<QLineEdit*>())
      {
          if(lineedit && !lineedit->text().isEmpty())
           {
                QString objName = lineedit->objectName();
                objName = objName.remove("lineEdit_");
                QString textentered = lineedit->text();
                qInfo()<<__FUNCTION__<<textentered;
      //            textemtered = lineedit->text().toUtf8().constData();
      //            qInfo()<<__FUNCTION__<<textemtered;
                settings->setValue(objName, textentered);
           }
      }
      settings->endGroup();
      settings->sync();
      

      But double backslashes are being added. one extra \ .
      In UI its ok, but in debug statements also \ and in the ini file also.
      c479eb8a-f28b-4033-bead-b58f554fcf90-image.png

      e61eb4f7-c56d-499f-894b-f9e8d6a68bc1-image.png

      same in INI file also
      c135ddd5-ac1b-4dd3-990b-f1a099ac6d3a-image.png

      Forward slash can't be used. these are signal urls

      How to get proper string from the lineedit->text() in the ini file like below
      f907e41f-086b-4753-9f8e-ba986dfb73e5-image.png

      C Offline
      C Offline
      ChrisW67
      wrote on 25 Jun 2024, 03:21 last edited by
      #3

      @sayan275 said in QLineedit adding extra \ from text():

      qInfo()<<__FUNCTION__<<textentered;

      When you use the QDebug functions the output is in the form of a C++ literal with anything that would need to be escaped inside the double-quotes, escaped. In this case the backslashes, but also any embedded double quote etc.

      1 Reply Last reply
      3
      • S sayan275
        24 Jun 2024, 17:29

        Am entering a string in QLineEdit as SIM VFB ALL.DataProcCycle.EmGenObjectList.aObject[.].Kinematic.fDistX*.
        Then am reading the text and creating ini file with qsettings.
        code is as below

        QSettings* settings = new QSettings(m_taskPath + SignalSettingsData::SIGNALSETTINGS_FILENAME, QSettings::IniFormat);
        settings->beginGroup(m_RadarSignalEditorUI->projectNameLbl->text());
        for(QLineEdit* lineedit : m_RadarSignalEditorUI->scrollAreaWidgetContents->findChildren<QLineEdit*>())
        {
            if(lineedit && !lineedit->text().isEmpty())
             {
                  QString objName = lineedit->objectName();
                  objName = objName.remove("lineEdit_");
                  QString textentered = lineedit->text();
                  qInfo()<<__FUNCTION__<<textentered;
        //            textemtered = lineedit->text().toUtf8().constData();
        //            qInfo()<<__FUNCTION__<<textemtered;
                  settings->setValue(objName, textentered);
             }
        }
        settings->endGroup();
        settings->sync();
        

        But double backslashes are being added. one extra \ .
        In UI its ok, but in debug statements also \ and in the ini file also.
        c479eb8a-f28b-4033-bead-b58f554fcf90-image.png

        e61eb4f7-c56d-499f-894b-f9e8d6a68bc1-image.png

        same in INI file also
        c135ddd5-ac1b-4dd3-990b-f1a099ac6d3a-image.png

        Forward slash can't be used. these are signal urls

        How to get proper string from the lineedit->text() in the ini file like below
        f907e41f-086b-4753-9f8e-ba986dfb73e5-image.png

        C Offline
        C Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on 24 Jun 2024, 17:49 last edited by
        #2

        @sayan275 said in QLineedit adding extra \ from text():

        How to get proper string from the lineedit->text() in the ini file like below

        You won't - the [ and ] must be properly encoded, also ..
        You will get the correct value when you read it back in with QSettings.

        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
        • S sayan275
          24 Jun 2024, 17:29

          Am entering a string in QLineEdit as SIM VFB ALL.DataProcCycle.EmGenObjectList.aObject[.].Kinematic.fDistX*.
          Then am reading the text and creating ini file with qsettings.
          code is as below

          QSettings* settings = new QSettings(m_taskPath + SignalSettingsData::SIGNALSETTINGS_FILENAME, QSettings::IniFormat);
          settings->beginGroup(m_RadarSignalEditorUI->projectNameLbl->text());
          for(QLineEdit* lineedit : m_RadarSignalEditorUI->scrollAreaWidgetContents->findChildren<QLineEdit*>())
          {
              if(lineedit && !lineedit->text().isEmpty())
               {
                    QString objName = lineedit->objectName();
                    objName = objName.remove("lineEdit_");
                    QString textentered = lineedit->text();
                    qInfo()<<__FUNCTION__<<textentered;
          //            textemtered = lineedit->text().toUtf8().constData();
          //            qInfo()<<__FUNCTION__<<textemtered;
                    settings->setValue(objName, textentered);
               }
          }
          settings->endGroup();
          settings->sync();
          

          But double backslashes are being added. one extra \ .
          In UI its ok, but in debug statements also \ and in the ini file also.
          c479eb8a-f28b-4033-bead-b58f554fcf90-image.png

          e61eb4f7-c56d-499f-894b-f9e8d6a68bc1-image.png

          same in INI file also
          c135ddd5-ac1b-4dd3-990b-f1a099ac6d3a-image.png

          Forward slash can't be used. these are signal urls

          How to get proper string from the lineedit->text() in the ini file like below
          f907e41f-086b-4753-9f8e-ba986dfb73e5-image.png

          C Offline
          C Offline
          ChrisW67
          wrote on 25 Jun 2024, 03:21 last edited by
          #3

          @sayan275 said in QLineedit adding extra \ from text():

          qInfo()<<__FUNCTION__<<textentered;

          When you use the QDebug functions the output is in the form of a C++ literal with anything that would need to be escaped inside the double-quotes, escaped. In this case the backslashes, but also any embedded double quote etc.

          1 Reply Last reply
          3
          • S sayan275 has marked this topic as solved on 22 Jul 2024, 04:08
          • S sayan275 has marked this topic as solved on 22 Jul 2024, 04:09

          3/3

          25 Jun 2024, 03:21

          • Login

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