Problem with a dynamicCall and a Qstring variable
I´m working in a program with scanning capabilities. For this work I use an ActiveX control from Pegasus. To this ActiveX control I make several dynamicCall(). All work fine , but I have find a problem.
the following code:
Code:
QList<QVariant> vars;
str2
=QInputDialog::getText(this,
"Write file´s name",
"Name: ");
vars<<str2;
str="SaveFile(QString)";
qDebug()<<str;
qDebug()<<str2;
qDebug()<<vars;
wmp->dynamicCall(str.toLatin1(),vars);
creates the folowing debugger output:
Code:
"SaveFile(QString)"
"c:\nnimagen"
All is ok and the dynamicCall works fine. I can save the scanned imagen.
But this other code:
Code:
QList<QVariant> vars;
str2="c:\nnimagen.bmp";
vars<<str2;
str="SaveFile(QString)";
qDebug()<<str;
qDebug()<<str2;
qDebug()<<vars;
wmp->dynamicCall(str.toLatin1(),vars);
creates this other debugger output:
Code:
"SaveFile(QString)"
"c:
nnimagen.bmp"
nimagen.bmp") )
In this case the "\n"caracters (from "c:\nnimage.bmp") are taken like a escape sequence, and the dynamicCall() produces an error.
If it is supposed that QInputDialog::getText returns a QString, ¿how is it posible? ?What is the diffecence betwen str2="c:\nnimagen.bmp" and str2=QInputDialog::getText(.......).
Why this error happens?.
How I must initializates the str2 QString?
Re: Problem with a dynamicCall and a Qstring variable
Try this:
Code:
str2
=QInputDialog::getText(this,
"Write file´s name",
"Name: ").
replace(QString("\"),QString("\\
"));
Re: Problem with a dynamicCall and a Qstring variable
Sorry , high_flyer. The str2=QInputDialog::getText(......) method work fine.
The problem appear when I create a str2 QString with this method:
Code:
str2="c:\nnimagen.bmp";
The "\n" sequence is taked as a escape sequence.
It is not a way to make this initialization without this error.
Added after 29 minutes
:
Thanks to high_flyer one of the questions is resolved.
We must initializate the str2 Qstring in this manner:
Code:
str2="c:\\nnimagen.bmp";
In this maner the \\ is considered as a escape sequence and converted to a singel \.
Thanks
Re: Problem with a dynamicCall and a Qstring variable
Quote:
one of the questions is resolved
What was the other question?
Re: Problem with a dynamicCall and a Qstring variable
So it is supossed that the QInputDialog::getText method do this conversion internally?
Re: Problem with a dynamicCall and a Qstring variable
No.
Why should it?
QInputDialog is just a convenience class for simple input.
It knows nothing about paths.