Hi all, here is an update...
I cant read through my xml file,
It stuck at
qDebug<<"reading"; part
continuos printing reading for output...
Please help check if there is any error.
This is saving to xml file, working fine
void Dialog::saveValue()
{
int h_slide1 = ui->hueSlide1->value();
int h_slide2 = ui->hueSlide2->value();
int s_slide1 = ui->satSlide1->value();
int s_slide2 = ui->satSlide2->value();
int l_slide1 = ui->lumSlide1->value();
int l_slide2 = ui->lumSlide2->value();
QFile valueHSV
("/home/pi/valueHSV/hsv.xml");
if(!valueHSV.
open(QIODevice::WriteOnly|QIODevice
::Text)) {
qDebug() << "cannot open file for writing"<<endl;
return;
}
QXmlStreamWriter hsv(&valueHSV);
hsv.setAutoFormatting(true);
hsv.writeStartDocument();
hsv.writeStartElement("HSV");
hsv.
writeTextElement("HUE LOW",
QString::number(h_slide1
));
hsv.
writeTextElement("HUE HIGH",
QString::number(h_slide2
));
hsv.
writeTextElement("SAT LOW",
QString::number(s_slide1
));
hsv.
writeTextElement("SAT HIGH",
QString::number(s_slide2
));
hsv.
writeTextElement("LUM LOW",
QString::number(l_slide1
));
hsv.
writeTextElement("LUM HIGH",
QString::number(l_slide2
));
hsv.writeEndElement();
hsv.writeEndDocument();
valueHSV.close();
}
void Dialog::saveValue()
{
int h_slide1 = ui->hueSlide1->value();
int h_slide2 = ui->hueSlide2->value();
int s_slide1 = ui->satSlide1->value();
int s_slide2 = ui->satSlide2->value();
int l_slide1 = ui->lumSlide1->value();
int l_slide2 = ui->lumSlide2->value();
QFile valueHSV("/home/pi/valueHSV/hsv.xml");
if(!valueHSV.open(QIODevice::WriteOnly|QIODevice::Text))
{
qDebug() << "cannot open file for writing"<<endl;
return;
}
QXmlStreamWriter hsv(&valueHSV);
hsv.setAutoFormatting(true);
hsv.writeStartDocument();
hsv.writeStartElement("HSV");
hsv.writeTextElement("HUE LOW",QString::number(h_slide1));
hsv.writeTextElement("HUE HIGH",QString::number(h_slide2));
hsv.writeTextElement("SAT LOW",QString::number(s_slide1));
hsv.writeTextElement("SAT HIGH",QString::number(s_slide2));
hsv.writeTextElement("LUM LOW",QString::number(l_slide1));
hsv.writeTextElement("LUM HIGH",QString::number(l_slide2));
hsv.writeEndElement();
hsv.writeEndDocument();
valueHSV.close();
}
To copy to clipboard, switch view to plain text mode
this is reading from xml part...
void Dialog::loadValue()
{
//QStringList list;
QFile valueHSV
("/home/pi/valueHSV/hsv.xml");
if(!valueHSV.
open(QIODevice::ReadOnly|QIODevice
::Text)) {
qDebug() << "cannot open file for reading"<<endl;
return;
}
else
{
QXmlStreamReader hsv(&valueHSV);
while(!hsv.atEnd())
{qDebug()<<"reading";
if(hsv.isStartElement())
{
qDebug()<<"here";
if(hsv.name()=="HSV")
{qDebug()<<"now";
if(hsv.name()=="HUE LOW")
{
ui->hueSlide1->setValue(hsv.readElementText().toInt());
qDebug()<<"1";
}
if(hsv.name()=="HUE HIGH")
{
ui->hueSlide2->setValue(hsv.readElementText().toInt());
}
if(hsv.name()=="SAT LOW")
{
ui->satSlide1->setValue(hsv.readElementText().toInt());
}
if(hsv.name()=="SAT HIGH")
{
ui->satSlide2->setValue(hsv.readElementText().toInt());
}
if(hsv.name()=="LUM LOW")
{
ui->lumSlide1->setValue(hsv.readElementText().toInt());
}
if(hsv.name()=="LUM HIGH")
{
ui->lumSlide2->setValue(hsv.readElementText().toInt());
}
}
}
}
}valueHSV.close();
}
void Dialog::loadValue()
{
//QStringList list;
QFile valueHSV("/home/pi/valueHSV/hsv.xml");
if(!valueHSV.open(QIODevice::ReadOnly|QIODevice::Text))
{
qDebug() << "cannot open file for reading"<<endl;
return;
}
else
{
QXmlStreamReader hsv(&valueHSV);
while(!hsv.atEnd())
{qDebug()<<"reading";
if(hsv.isStartElement())
{
qDebug()<<"here";
if(hsv.name()=="HSV")
{qDebug()<<"now";
if(hsv.name()=="HUE LOW")
{
ui->hueSlide1->setValue(hsv.readElementText().toInt());
qDebug()<<"1";
}
if(hsv.name()=="HUE HIGH")
{
ui->hueSlide2->setValue(hsv.readElementText().toInt());
}
if(hsv.name()=="SAT LOW")
{
ui->satSlide1->setValue(hsv.readElementText().toInt());
}
if(hsv.name()=="SAT HIGH")
{
ui->satSlide2->setValue(hsv.readElementText().toInt());
}
if(hsv.name()=="LUM LOW")
{
ui->lumSlide1->setValue(hsv.readElementText().toInt());
}
if(hsv.name()=="LUM HIGH")
{
ui->lumSlide2->setValue(hsv.readElementText().toInt());
}
}
}
}
}valueHSV.close();
}
To copy to clipboard, switch view to plain text mode
Please advise.
Thanks in advance
Best Regards
YDYD
Bookmarks