i am facing a problem with QTextEdit!!!
hello,
i connected to a database that contains text which is non english language(right to left language) i used the following code to show the text:
mainText->setText(query.value(0).toString());
but when the text appears on the QtextEdit it appears with strange characters
i tried the following experiments and they failed
mainText->setText(QString::fromLocal8Bit(query.value(0).toS tring()));
mainText->setText(query.value(0).tochar());
can any body help me???
thank you.
Re: i am facing a problem with QTextEdit!!!
Quote:
Originally Posted by
mismael85
mainText->setText(query.value(0).toString());
This should be enough provided that you have a font that contains all required characters.
How did you insert data into the database?
Re: i am facing a problem with QTextEdit!!!
i inserted the data by keyboard.
note i faced this problem before when i tried to open file which is contained in a folder named by a right to left laguage when i tried to take the file name from argv[1] variable
of the main function and i solved this problem by using the following code
QString::fromLocal8Bit(arvg[1]);
and the problem is solved but when i tried to do this with current situation the compiler says
error C2664: 'QString::fromLocal8Bit' : cannot convert parameter 1 from 'QString' to 'const char *'
!!!!
Re: i am facing a problem with QTextEdit!!!
Quote:
Originally Posted by
mismael85
i inserted the data by keyboard.
Are you sure that the data in the database is in correct encoding? What database do you use? What encoding does it use? What encoding does your system use? What application did you use to enter the data?
Quote:
Originally Posted by
mismael85
i tried to take the file name from argv[1] variable
of the main function and i solved this problem by using the following code
QString::fromLocal8Bit(arvg[1]);
That's a different case. Qt should get data from the database in correct form all by itself.
Re: i am facing a problem with QTextEdit!!!
Quote:
Are you sure that the data in the database is in correct encoding?
yes i am sure it is a plain text.
Quote:
What database do you use?
i am using microsoft access database.
Quote:
What encoding does your system use?
i am using windows xp
Quote:
What application did you use to enter the data?
i am using microsoft access.
Re: i am facing a problem with QTextEdit!!!
i made a new database and i entered right to left text. and showed it to QTextEdit
and it appears successfully.
but with my old database which is made by MS access 97 the text are not appears
correctly.
Re: i am facing a problem with QTextEdit!!!
when i converted the database to MS access 2003 the text displayed fine.
i don't know why!!!
but i should operate on access 97 because i don't own the database i am just using it.
Re: i am facing a problem with QTextEdit!!!
Quote:
Originally Posted by
mismael85
when i converted the database to MS access 2003 the text displayed fine.
So either data in the other database uses wrong encoding or there is something wrong with the ODBC driver for that database and most likely it's the latter. For example Qt might not be able to negotiate the encoding with the driver.
Can you see properly the data you insert into the database using Qt?
Re: i am facing a problem with QTextEdit!!!
i tried to insret data using Qt to the database that are converted to access 2002.
but only that data are displayed with strange carachters.
Re: i am facing a problem with QTextEdit!!!
Quote:
Originally Posted by
mismael85
but only that data are displayed with strange carachters.
How do you insert that data then?