I am tring to shift enter chararter by 2 . That mean char "A" to "c".
How it should work:
1> I collect QString from LineEdit.
2>Than get each ASCII value of SQtring
3> Add 2 to ASCII Value
4> Convert it to QString
5> Show it to Thru LineEdit2
Code:
Printable View
I am tring to shift enter chararter by 2 . That mean char "A" to "c".
How it should work:
1> I collect QString from LineEdit.
2>Than get each ASCII value of SQtring
3> Add 2 to ASCII Value
4> Convert it to QString
5> Show it to Thru LineEdit2
Code:
So what is the problem exactly? If you make 'chVale' a char, it should work fine.
These problem are showen on building:
1>'QChar::QChar(char)' is private
2>within this context
3>'chVal' was not declared in this scope
what happens if you change chValue a char, instead of int ? as wysota said ?
Also the code and error doesnt match,, in error u say 'chaVal' but in code I dont see any such variable
Also in pass3 += QChar(chVale); is chVale declared ?
Ok, It was my typing mistake.
I changed chVale to chValue and again compiled it and i got following error :
1>'QChar::QChar(char)' is private
2>within this context
And please tell what does 1 and 2 means.
It means you need to learn C++.
Are you using Qt4 or Qt3? Qt4 (which is what your profile suggests you are using) surely has a public constructor taking a char so you shouldn't be getting that error.
How to do what? Please provide the exact code you have now because right now we are chasing ghosts.
This is what I want:
---------------------------------------------------
1> I collect QString from LineEdit.
2>Than get each ASCII value of SQtring
3> Add 2 to ASCII Value
4> Convert it to QString
5> Show it to Thru LineEdit2
// cpp
Code:
void myapp01r::myappstr() { QString pass3; QChar ch,ch2; int i,chValue; // Get Data // QString to char array; for(i=0; i<=str.size();i++) { // converted to number ch=str.at(i).toAscii(); chValue = ch.toAscii(); chValue=chValue + 2; // Number to Charecter and string in QSTRING pass3 += char(chValue); } ui->lineEdit_2->setText(pass3); }
header
Code:
private slots: void myappstr();
And what is the error? With lines and everything, please.
BTW. You are modifying the value of the character by 2 but then you are not using it anywhere.
I have changed it.
AND I am getting following error
1>'QChar::QChar(char)' is private
2>within this context
Within what context? Please, read again what I asked you to do:
1. provide the exact code you are currently using
2. provide the errors you are getting including line numbers where the errors occur
and also:
3. Skip those "1>", "2>", etc. from your posts, they are really annoying and yield no value to the problem.