PDA

View Full Version : char array to qstring



vani.pv
14th August 2012, 08:07
hi.........
I am new to qt...so please clarify my doubt ....

I need to convert char array to string......which i need to assigned as a text of qtable.







Thanks....

spirit
14th August 2012, 08:10
QString::QString takes const char *...

yeye_olive
14th August 2012, 09:57
I need to convert char array to string
The solution depends on the encoding used to represent text in the char array. QString has a few convenience functions for a few common ones (fromAscii(), fromLatin1(), fromUtf8()) and the encoding defined by the current locale (fromLocal8Bit()). For more options see the QTextCodec class.

vani.pv
16th August 2012, 10:58
thanks.....i will try it......

I have a other question regarding qsocket....I have a one pedestal system to which i need to pass a command through ethernet......so I need to work with qsocket.
but while running my program there is no status update from my socket state.It is always showing "CONNECTING" state.i am not getting how to solve it.


Here is my code...

ui.h:


QSocket *sock;

in a button clicked functon ..........
{
sock->connectToHost(ipaddress,portnum);
if(sock->state() == QSocket::connecting)
printing some message.......

else if(sock->state() == QSocket::connected)
printing some message.......

else if(sock->state() == QSocket::Idle)
printing some message.......
}






thanks......

spirit
16th August 2012, 11:04
You should catch QAbstractSocket::connected signal or use QAbstractSocket::waitForConnected in case you are using blocking sockets.
PS. Use tags CODE next time.