Results 1 to 13 of 13

Thread: Qstring conversion UTF8

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2010
    Posts
    41
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Question Qstring conversion UTF8

    I am trying to convert a Qstring to UTF8 for a mysql query. I am getting the following error.

    1>.\thewge.cpp(54) : error C2039: 'utf8' : is not a member of 'QString'
    1> c:\qt\4.6.2\include\qtcore\../../src/corelib/tools/qstring.h(91) : see declaration of 'QString'
    1>.\thewge.cpp(55) : error C2039: 'utf8' : is not a member of 'QString'
    1> c:\qt\4.6.2\include\qtcore\../../src/corelib/tools/qstring.h(91) : see declaration of 'QString'

    Qt Code:
    1. QString Qstr1 = ui.usrLineEdit->text();
    2. QString Qstr2 = ui.pwdLineEdit->text();
    3.  
    4. char *acsUserName = Qstr1.utf8();
    5. char *acsPassword = Qstr2.utf8();
    To copy to clipboard, switch view to plain text mode 

    I also tried this.
    Qt Code:
    1. QString Qstr1 = ui.usrLineEdit->text();
    2. QString Qstr2 = ui.pwdLineEdit->text();
    3.  
    4. char *acsUserName = Qstr1.toUtf8();
    5. char *acsPassword = Qstr2.toUtf8();
    To copy to clipboard, switch view to plain text mode 

    and got these errors:

    1>.\thewge.cpp(53) : error C2440: 'initializing' : cannot convert from 'QByteArray' to 'char *'
    1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
    1>.\thewge.cpp(54) : error C2440: 'initializing' : cannot convert from 'QByteArray' to 'char *'
    1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
    Last edited by harleyskater; 24th June 2010 at 09:01.

Similar Threads

  1. BSTR to QString Conversion
    By bismitapadhy in forum Qt Programming
    Replies: 9
    Last Post: 16th February 2012, 12:51
  2. char* to QString: conversion
    By abghosh in forum Qt Programming
    Replies: 9
    Last Post: 8th March 2010, 09:32
  3. qreal -> QString conversion
    By MarkoSan in forum Newbie
    Replies: 2
    Last Post: 13th April 2008, 14:37
  4. QString iso 8859-1 conversion
    By mattia in forum Newbie
    Replies: 11
    Last Post: 21st January 2008, 14:17
  5. UTF8 to ISO 8859... conversion
    By claudio in forum Qt Programming
    Replies: 3
    Last Post: 29th December 2007, 21:24

Tags for this Thread

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.