QLineedit adding extra \ from text()
-
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 belowQSettings* 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.
same in INI file also
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
-
@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.
-
@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. -
@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.
-
-