[SOLVED]QFile Question
-
Hi all,
Now i have a method as following
@void Dialog::saveValue()
{
QString path="/home/pi/valueHSV/hsv.xml";
QFile valueHSV(path);
valueHSV.open(QIODevice::WriteOnly);
...
}@I would like to change the "path" in different situation,
I tried writing a switch case in different method and call to saveValue mathod, this won't work,
I tried to do a switch case inside saveValue method, this won't work too.Please advise, Thanks
-
Hope it is as simple as this. You can pass the path of the file itself to function.
@
void Dialog::saveValue(QString path) {
QFile valueHSV(path);
valueHSV.open(QIODevice::WriteOnly); ...
valueHSV.close()
}
@ -
So i need another function for the switch case of path?
for e.g.
@void Dialog::switchX(QString path)
{
char x;
switch(x)
case 'a':
path = "....";break;case'b':
path = "....";break;
}@ -
Not sure about your logic. If you would like to pass the path based on different condition, you need to have case statement or if or something else.
-
HI
if i pass QString path from other function to saveValue(QString path)
this would affect my saveValue act as a SLOT,
Object::connect: No such slot Dialog
any otehr mothod?
-
you need to change the slot signature in your dialog class. Can you paste your dialog class here ?
-
This is code
-
continue
@a@ -
looking at your code
-
You can define one slot connecting this to your slider e.g sliderValue(int)
-
Change the signature of saveValue to saveValue(QString path)
-
From sliderValue(int val) {
switch(val) {
case 1:
saveValue(path1);breakcase 2 : saveValue(path2);break case 3 : saveValue(path3);break }
}
-
-
ok, Thanks! =) get it!