PDA

View Full Version : help me to slove



askrina
14th April 2010, 21:31
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


QString pass3;
QChar ch;
int i,chValue;


// Get Data
QString str = ui->lineEdit->text();

// 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 += QChar(chVale);

}

ui->lineEdit_2->setText(pass3);

wysota
14th April 2010, 21:42
So what is the problem exactly? If you make 'chVale' a char, it should work fine.

askrina
15th April 2010, 04:36
These problem are showen on building:

1>'QChar::QChar(char)' is private
2>within this context
3>'chVal' was not declared in this scope

aamer4yu
15th April 2010, 05:40
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 ?

askrina
15th April 2010, 09:24
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.

wysota
15th April 2010, 09:29
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.

askrina
15th April 2010, 09:42
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.


Yes, I am new to C++ and I m using QT4 with sdk.

Can u show how to do that.

wysota
15th April 2010, 10:10
How to do what? Please provide the exact code you have now because right now we are chasing ghosts.

askrina
15th April 2010, 10:18
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

void myapp01r::myappstr()
{

QString pass3;
QChar ch,ch2;
int i,chValue;


// Get Data
QString str = ui->lineEdit->text();

// 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

private slots:
void myappstr();

wysota
15th April 2010, 10:42
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.

askrina
15th April 2010, 11:05
I have changed it.
AND I am getting following error
1>'QChar::QChar(char)' is private
2>within this context

wysota
15th April 2010, 11:44
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.