Results 1 to 5 of 5

Thread: char array to qstring

  1. #1
    Join Date
    Aug 2012
    Posts
    33
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default char array to qstring

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

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: char array to qstring

    QString::QString takes const char *...
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: char array to qstring

    Quote Originally Posted by vani.pv View Post
    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.

  4. #4
    Join Date
    Aug 2012
    Posts
    33
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: char array to qstring

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

  5. #5
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: char array to qstring

    You should catch QAbstractSocket::connected signal or use QAbstractSocket::waitForConnected in case you are using blocking sockets.
    PS. Use tags CODE next time.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

Similar Threads

  1. Char array[6] to QString and display it
    By arunvv in forum Newbie
    Replies: 11
    Last Post: 12th March 2014, 20:48
  2. Char array to QString
    By gab74 in forum Newbie
    Replies: 11
    Last Post: 13th December 2011, 15:54
  3. converiosn of hex data char array to Qstring
    By manoagp in forum Qt Programming
    Replies: 1
    Last Post: 17th March 2010, 09:04
  4. Converting QString to char array
    By srohit24 in forum Qt Programming
    Replies: 3
    Last Post: 22nd July 2009, 18:19
  5. Char Array to QString
    By 3nc31 in forum Qt Programming
    Replies: 2
    Last Post: 25th November 2007, 22:18

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.