锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
璋冩暣鍒嗚鯨鐜囩殑浠g爜濡備笅錛?br>DEVMODE dm;
dm.dmSize = sizeof(DEVMODE) ;
EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&dm);
if(dm.dmPelsHeight!=1024||dm.dmPelsWidth!=1280){
if(AfxMessageBox("涓轟簡杈懼埌鏈濂界殑鏄劇ず鏁堟灉錛屽緩璁偍浣跨敤1280*1024鐨勫垎杈ㄧ巼錛岀‘瀹氬悧錛?,MB_YESNO)==IDYES){
LONG result;
dm.dmBitsPerPel = 32;
dm.dmPelsHeight = 1024;
dm.dmPelsWidth = 1280;
dm.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
result = ChangeDisplaySettings(&dm,0);
}
}
“濡傛灉瑕佸湪紼嬪簭鍚姩鏃惰嚜鍔ㄨ嚜鍔ㄨ皟鏁村埌鍚堥傜殑鍒嗚鯨鐜囷紝鍙互灝嗗叾鍔犲叆鍒癡iew鐨凮nInitialUpdate()涓紝騫惰褰曚笅dm.dmPelsHeight鍜宒m.dmPelsWidth鐨勫箋?br>瑕佸湪紼嬪簭緇撴潫鏃惰嚜鍔ㄨ皟鏁村洖鍘熸湁鍒嗚鯨鐜囷紝鍙湪MainFrame鐨凮nClose()涓敤浠ヤ笂浠g爜灝嗗叾鏀瑰洖鍘熷箋?#8221;
濡傛灉瑕佸湪紼嬪簭鍚姩鏃惰嚜鍔ㄨ嚜鍔ㄨ皟鏁村埌鍚堥傜殑鍒嗚鯨鐜囷紝鍙互灝嗗叾鍔犲叆鍒癮pp鐨処nitInstance()涓紝騫惰褰曚笅dm.dmPelsHeight鍜宒m.dmPelsWidth鐨勫箋?br>瑕佸湪紼嬪簭緇撴潫鏃惰嚜鍔ㄨ皟鏁村洖鍘熸湁鍒嗚鯨鐜囷紝鍙湪APP鐨凟xitInstance涓敤浠ヤ笂浠g爜灝嗗叾鏀瑰洖鍘熷箋?#8221;
瑙e喅鍔炴硶:
鍔?include
#ifndef VECMAT_H
# define VECMAT_H
# include <cmath>
# include <vector>
# include <iostream>
namespace vecmat {
namespace internal {
template <bool B>
struct is_false {};
template <>
struct is_false<false> {
static inline void ensure() {}
};
} // end of namespace internal
//
// Vector class
// - T: value type
// - N: dimension
//
/////////////////////////////////////////////////////////////////////////////
template <class T, unsigned N>
class Vector
{
public:
typedef T value_type;
// constructors
inline Vector() {
for (unsigned i = 0; i < N; i++)
_coord[i] = 0;
}
~Vector() {
internal::is_false<(N == 0)>::ensure();
}
template <class U>
explicit inline Vector(const U tab[N]) {
for (unsigned i = 0; i < N; i++)
_coord[i] = (T)tab[i];
}
template <class U>
explicit inline Vector(const std::vector<U>& tab) {
for (unsigned i = 0; i < N; i++)
_coord[i] = (T)tab[i];
}
template <class U>
explicit inline Vector(const Vector<U, N>& v) {
for (unsigned i = 0; i < N; i++)
_coord[i] = (T)v[i];
}
// accessors
inline value_type operator[](const unsigned i) const {
return _coord[i];
}
inline value_type& operator[](const unsigned i) {
return _coord[i];
}
static inline unsigned dim() {
return N;
}
// various useful methods
inline value_type norm() const {
return (T)sqrt(squareNorm());
}
inline value_type squareNorm() const {
return (*this) * (*this);
}
inline Vector<T, N>& normalize() {
value_type n = norm();
for (unsigned i = 0; i < N; i++)
_coord[i] /= n;
return *this;
}
inline Vector<T, N>& normalizeSafe() {
value_type n = norm();
if (n)
for (unsigned i=0; i < N; i++)
_coord[i] /= n;
return *this;
}
inline Vector<T, N>& min(const Vector<T, N>& v) {
for (unsigned i=0; i < N; i++)
if (_coord[i] > v._coord[i])
_coord[i] = v._coord[i];
return *this;
}
inline Vector<T, N>& max(const Vector<T, N>& v) {
for (unsigned i=0; i < N; i++)
if (_coord[i] < v._coord[i])
_coord[i] = v._coord[i];
return *this;
}
inline const value_type* address() const {
return _coord;
}
// classical operators
template <class U>
inline Vector<T, N>& operator=(const Vector<U, N>& v) {
if (this != &v)
for (unsigned i = 0; i < N; i++)
_coord[i] = (T)v[i];
return *this;
}
template <class U>
inline Vector<T, N>& operator+=(const Vector<U, N>& v) {
for (unsigned i = 0 ; i < N; i++)
_coord[i] += (T)v[i];
return *this;
}
template <class U>
inline Vector<T, N>& operator-=(const Vector<U, N>& v) {
for (unsigned i = 0 ; i < N; i++)
_coord[i] -= (T)v[i];
return *this;
}
template <class U>
inline Vector<T, N>& operator*=(const U r) {
for (unsigned i = 0 ; i < N; i++)
_coord[i] *= r;
return *this;
}
template <class U>
inline Vector<T, N>& operator/=(const U r) {
if (r)
for (unsigned i = 0 ; i < N; i++)
_coord[i] /= r;
return *this;
}
inline bool operator==(const Vector<T, N>& v) const {
for(unsigned i = 0; i < N; i++)
if (_coord[i] != v[i])
return false;
return true;
}
inline bool operator!=(const Vector<T, N>& v) const {
for(unsigned i = 0; i < N; i++)
if (_coord[i] != v[i])
return true;
return false;
}
inline bool operator<(const Vector<T, N>& v) const {
for (unsigned i = 0; i<N; i++) {
if (_coord[i] < v[i])
return true;
if (_coord[i] > v[i])
return false;
if (_coord[i] == v[i])
continue;
}
return false;
}
inline bool operator>(const Vector<T, N>& v) const {
for (unsigned i=0; i<N; i++) {
if(_coord[i] > v[i])
return true;
if(_coord[i] < v[i])
return false;
if(_coord[i] == v[i])
continue;
}
return false;
}
protected:
value_type _coord[N];
enum {
_dim = N,
};
};
//
// Vec2 class (2D Vector)
// - T: value type
//
/////////////////////////////////////////////////////////////////////////////
template <class T>
class Vec2 : public Vector<T, 2>
{
public:
typedef typename Vector<T, 2>::value_type value_type;
inline Vec2() : Vector<T, 2>() {}
template <class U>
explicit inline Vec2(const U tab[2]) : Vector<T, 2>(tab) {}
template <class U>
explicit inline Vec2(const std::vector<U>& tab) : Vector<T, 2>(tab) {}
template <class U>
inline Vec2(const Vector<U, 2>& v) : Vector<T, 2>(v) {}
inline Vec2(const value_type x,
const value_type y = 0) : Vector<T, 2>() {
this->_coord[0] = (T)x;
this->_coord[1] = (T)y;
}
inline value_type x() const {
return this->_coord[0];
}
inline value_type& x() {
return this->_coord[0];
}
inline value_type y() const {
return this->_coord[1];
}
inline value_type& y() {
return this->_coord[1];
}
};
//
// HVec3 class (3D Vector in homogeneous coordinates)
// - T: value type
//
/////////////////////////////////////////////////////////////////////////////
template <class T>
class HVec3 : public Vector<T, 4>
{
public:
typedef typename Vector<T, 4>::value_type value_type;
inline HVec3() : Vector<T, 4>() {}
template <class U>
explicit inline HVec3(const U tab[4]) : Vector<T, 4>(tab) {}
template <class U>
explicit inline HVec3(const std::vector<U>& tab) : Vector<T, 4>(tab) {}
template<class U>
inline HVec3(const Vector<U, 4>& v) : Vector<T, 4>(v) {}
inline HVec3(const value_type sx,
const value_type sy = 0,
const value_type sz = 0,
const value_type s = 1) {
this->_coord[0] = sx;
this->_coord[1] = sy;
this->_coord[2] = sz;
this->_coord[3] = s;
}
template <class U>
inline HVec3(const Vector<U, 3>& sv) {
this->_coord[0] = (T)sv[0];
this->_coord[1] = (T)sv[1];
this->_coord[2] = (T)sv[2];
this->_coord[3] = (T)1;
}
template <class U>
inline HVec3(const Vector<U, 3>& sv,
const U) {
this->_coord[0] = (T)sv[0];
this->_coord[1] = (T)sv[1];
this->_coord[2] = (T)sv[2];
this->_coord[3] = (T)s;
}
inline value_type sx() const {
return this->_coord[0];
}
inline value_type& sx() {
return this->_coord[0];
}
inline value_type sy() const {
return this->_coord[1];
}
inline value_type& sy() {
return this->_coord[1];
}
inline value_type sz() const {
return this->_coord[2];
}
inline value_type& sz() {
return this->_coord[2];
}
inline value_type s() const {
return this->_coord[3];
}
inline value_type& s() {
return this->_coord[3];
}
// Acces to non-homogeneous coordinates in 3D
inline value_type x() const {
return this->_coord[0] / this->_coord[3];
}
inline value_type y() const {
return this->_coord[1] / this->_coord[3];
}
inline value_type z() const {
return this->_coord[2] / this->_coord[3];
}
};
//
// Vec3 class (3D Vector)
// - T: value type
//
/////////////////////////////////////////////////////////////////////////////
template <class T>
class Vec3 : public Vector<T, 3>
{
public:
typedef typename Vector<T, 3>::value_type value_type;
inline Vec3() : Vector<T, 3>() {}
template <class U>
explicit inline Vec3(const U tab[3]) : Vector<T, 3>(tab) {}
template <class U>
explicit inline Vec3(const std::vector<U>& tab) : Vector<T, 3>(tab) {}
template<class U>
inline Vec3(const Vector<U, 3>& v) : Vector<T, 3>(v) {}
template<class U>
inline Vec3(const HVec3<U>& v) {
this->_coord[0] = (T)v.x();
this->_coord[1] = (T)v.y();
this->_coord[2] = (T)v.z();
}
inline Vec3(const value_type x,
const value_type y = 0,
const value_type z = 0) : Vector<T, 3>() {
this->_coord[0] = x;
this->_coord[1] = y;
this->_coord[2] = z;
}
inline value_type x() const {
return this->_coord[0];
}
inline value_type& x() {
return this->_coord[0];
}
inline value_type y() const {
return this->_coord[1];
}
inline value_type& y() {
return this->_coord[1];
}
inline value_type z() const {
return this->_coord[2];
}
inline value_type& z() {
return this->_coord[2];
}
};
//
// Matrix class
// - T: value type
// - M: rows
// - N: cols
//
/////////////////////////////////////////////////////////////////////////////
// Dirty, but icc under Windows needs this
# define _SIZE (M * N)
template <class T, unsigned M, unsigned N>
class Matrix
{
public:
typedef T value_type;
inline Matrix() {
for (unsigned i = 0; i < _SIZE; i++)
this->_coord[i] = 0;
}
~Matrix() {
internal::is_false<(M == 0)>::ensure();
internal::is_false<(N == 0)>::ensure();
}
template <class U>
explicit inline Matrix(const U tab[M][N]) {
for (unsigned i = 0; i < M; i++)
for (unsigned j = 0; j < N; j++)
this->_coord[i * N + j] = tab[i][j];
}
template <class U>
explicit inline Matrix(const U tab[_SIZE]) {
for (unsigned i = 0; i < _SIZE; i++)
this->_coord[i] = tab[i];
}
template <class U>
explicit inline Matrix(const std::vector<U>& tab) {
for (unsigned i = 0; i < _SIZE; i++)
this->_coord[i] = tab[i];
}
template <class U>
inline Matrix(const Matrix<U, M, N>& m) {
for (unsigned i = 0; i < M; i++)
for (unsigned j = 0; j < N; j++)
this->_coord[i * N + j] = (T)m(i, j);
}
inline value_type operator()(const unsigned i, const unsigned j) const {
return this->_coord[i * N + j];
}
inline value_type& operator()(const unsigned i, const unsigned j) {
return this->_coord[i * N + j];
}
static inline unsigned rows() {
return M;
}
static inline unsigned cols() {
return N;
}
inline Matrix<T, M, N> transpose() const {
Matrix<T, N, M> res;
for (unsigned i = 0; i < M; i++)
for (unsigned j = 0; j < N; j++)
res(j,i) = this->_coord[i * N + j];
return res;
}
inline void getArray(value_type res[M][N]) const {
for (unsigned i = 0; i < M; i++)
for (unsigned j = 0; j < N; j++)
res[i][j] = this->_coord[i * N + j];
}
inline void getArray(value_type res[_SIZE]) const {
for (unsigned i = 0; i < _SIZE; i++)
res[i] = this->_coord[i];
}
inline const value_type* address() const {
return this->_coord;
}
template <class U>
inline Matrix<T, M, N>& operator=(const Matrix<U, M, N>& m) {
if (this != &m)
for (unsigned i = 0; i < M; i++)
for (unsigned j = 0; j < N; j++)
this->_coord[i * N + j] = (T)m(i, j);
return *this;
}
template <class U>
inline Matrix<T, M, N>& operator+=(const Matrix<U, M, N>& m) {
for (unsigned i = 0; i < M; i++)
for (unsigned j = 0; j < N; j++)
this->_coord[i * N + j] += (T)m(i, j);
return *this;
}
template <class U>
inline Matrix<T, M, N>& operator-=(const Matrix<U, M, N>& m) {
for (unsigned i = 0; i < M; i++)
for (unsigned j = 0; j < N; j++)
this->_coord[i * N + j] -= (T)m(i, j);
return *this;
}
template <class U>
inline Matrix<T, M, N>& operator*=(const U lambda) {
for (unsigned i = 0; i < M; i++)
for (unsigned j = 0; j < N; j++)
this->_coord[i * N + j] *= lambda;
return *this;
}
template <class U>
inline Matrix<T, M, N>& operator/=(const U lambda) {
if (lambda)
for (unsigned i = 0; i < M; i++)
for (unsigned j = 0; j < N; j++)
this->_coord[i * N + j] /= lambda;
return *this;
}
protected:
value_type _coord[_SIZE];
};
//
// SquareMatrix class
// - T: value type
// - N: rows & cols
//
/////////////////////////////////////////////////////////////////////////////
// Dirty, but icc under Windows needs this
# define __SIZE (N * N)
template <class T, unsigned N>
class SquareMatrix : public Matrix<T, N, N>
{
public:
typedef T value_type;
inline SquareMatrix() : Matrix<T, N, N>() {}
template <class U>
explicit inline SquareMatrix(const U tab[__SIZE]) : Matrix<T, N, N>(tab) {}
template <class U>
explicit inline SquareMatrix(const std::vector<U>& tab) : Matrix<T, N, N>(tab) {}
template <class U>
inline SquareMatrix(const Matrix<U, N, N>& m) : Matrix<T, N, N>(m) {}
static inline SquareMatrix<T, N> identity() {
SquareMatrix<T, N> res;
for (unsigned i = 0; i < N; i++)
res(i, i) = 1;
return res;
}
};
//
// Vector external functions
//
/////////////////////////////////////////////////////////////////////////////
template <class T, unsigned N>
inline Vector<T, N> operator+(const Vector<T, N>& v1,
const Vector<T, N>& v2) {
Vector<T, N> res(v1);
res += v2;
return res;
}
template <class T, unsigned N>
inline Vector<T, N> operator-(const Vector<T, N>& v1,
const Vector<T, N>& v2) {
Vector<T, N> res(v1);
res -= v2;
return res;
}
template <class T, unsigned N>
inline Vector<T, N> operator*(const Vector<T, N>& v,
const typename Vector<T, N>::value_type r) {
Vector<T, N> res(v);
res *= r;
return res;
}
template <class T, unsigned N>
inline Vector<T, N> operator*(const typename Vector<T, N>::value_type r,
const Vector<T, N>& v) {
Vector<T, N> res(v);
res *= r;
return res;
}
template <class T, unsigned N>
inline Vector<T, N> operator/(const Vector<T, N>& v,
const typename Vector<T, N>::value_type r) {
Vector<T, N> res(v);
if (r)
res /= r;
return res;
}
// dot product
template <class T, unsigned N>
inline typename Vector<T, N>::value_type operator*(const Vector<T, N>& v1,
const Vector<T, N>& v2) {
typename Vector<T, N>::value_type sum = 0;
for (unsigned i = 0; i < N; i++)
sum += v1[i] * v2[i];
return sum;
}
// cross product for 3D Vectors
template <typename T>
inline Vec3<T> operator^(const Vector<T, 3>& v1,
const Vector<T, 3>& v2) {
Vec3<T> res(v1[1] * v2[2] - v1[2] * v2[1],
v1[2] * v2[0] - v1[0] * v2[2],
v1[0] * v2[1] - v1[1] * v2[0]);
return res;
}
// stream operator
template <class T, unsigned N>
inline std::ostream& operator<<(std::ostream& s,
const Vector<T, N>& v) {
unsigned i;
s << "[";
for (i = 0; i < N - 1; i++)
s << v[i] << ", ";
s << v[i] << "]";
return s;
}
//
// Matrix external functions
//
/////////////////////////////////////////////////////////////////////////////
template <class T, unsigned M, unsigned N>
inline Matrix<T, M, N>
operator+(const Matrix<T, M, N>& m1,
const Matrix<T, M, N>& m2) {
Matrix<T, M, N> res(m1);
res += m2;
return res;
}
template <class T, unsigned M, unsigned N>
inline Matrix<T, M, N>
operator-(const Matrix<T, M, N>& m1,
const Matrix<T, M, N>& m2) {
Matrix<T, M, N> res(m1);
res -= m2;
return res;
}
template <class T, unsigned M, unsigned N>
inline Matrix<T, M, N>
operator*(const Matrix<T, M, N>& m1,
const typename Matrix<T, M, N>::value_type lambda) {
Matrix<T, M, N> res(m1);
res *= lambda;
return res;
}
template <class T, unsigned M, unsigned N>
inline Matrix<T, M, N>
operator*(const typename Matrix<T, M, N>::value_type lambda,
const Matrix<T, M, N>& m1) {
Matrix<T, M, N> res(m1);
res *= lambda;
return res;
}
template <class T, unsigned M, unsigned N>
inline Matrix<T, M, N>
operator/(const Matrix<T, M, N>& m1,
const typename Matrix<T, M, N>::value_type lambda) {
Matrix<T, M, N> res(m1);
res /= lambda;
return res;
}
template <class T, unsigned M, unsigned N, unsigned P>
inline Matrix<T, M, P>
operator*(const Matrix<T, M, N>& m1,
const Matrix<T, N, P>& m2) {
unsigned i, j, k;
Matrix<T, M, P> res;
typename Matrix<T, N, P>::value_type scale;
for (j = 0; j < P; j++) {
for (k = 0; k < N; k++) {
scale = m2(k, j);
for (i = 0; i < N; i++)
res(i, j) += m1(i, k) * scale;
}
}
return res;
}
template <class T, unsigned M, unsigned N>
inline Vector<T, M>
operator*(const Matrix<T, M, N>& m,
const Vector<T, N>& v) {
Vector<T, M> res;
typename Matrix<T, M, N>::value_type scale;
for (unsigned j = 0; j < M; j++) {
scale = v[j];
for (unsigned i = 0; i < N; i++)
res[i] += m(i, j) * scale;
}
return res;
}
// stream operator
template <class T, unsigned M, unsigned N>
inline std::ostream& operator<<(std::ostream& s,
const Matrix<T, M, N>& m) {
unsigned i, j;
for (i = 0; i < M; i++) {
s << "[";
for (j = 0; j < N - 1; j++)
s << m(i, j) << ", ";
s << m(i, j) << "]" << std::endl;
}
return s;
}
} // end of namespace vecmat
#endif // VECMAT_H
鍘熷洜鏄湪windows鐨勫ご鏂囦歡閲宮ax錛宮in宸茬粡琚畾涔夋垚瀹忎簡錛屾墍浠ヨ鍑洪棶棰?
瑙e喅鏂規硶錛?br>鐢?br>#ifdef max
#undef max
#endif
鍘繪帀max鐨勫畾涔夈?br>min鍚屼笂銆?/span>
闂瑙e喅銆?/p>
濡傛灉涓婅堪閮戒笉琛岋細
CString杞崲涓篶har*
CString origCString("Hello, World!");
wchar_t* wCharString = origCString.GetBuffer(origCString.GetLength()+1);
size_t origsize = wcslen(wCharString) + 1;
size_t convertedChars = 0;
char *CharString;
CharString=new char(origsize);
wcstombs_s(&convertedChars, CharString, origsize, wCharString , _TRUNCATE);
cout << CharString << endl;
鎴愬姛杈撳嚭瀛楃涓?Hello,World"
鍘熷洜錛?br>鍘熸潵鍦╒C++ 2005浠ュ墠錛屽簲鐢ㄧ▼搴忛粯璁ら兘鏄叧闂Unicode鐨勬敮鎸佺殑錛岃屽湪VC2005涓紝榛樿鎵撳紑浜嗗瀹冪殑鏀寔錛孋String瀵瑰簲鐨勫瓧絎︿覆搴旇鏄疶CHAR錛孴CHAR鐨勫畾涔夋槸榪欐牱鐨勶紝
#ifdef _UNICODE
typedef wchar_t TCHAR ;
#else
typedef char TCHAR;
#endif
鎵浠ュ湪宸ョ▼涓簲璇ュ彲浠ュ叧闂浜嶶nicode鐨勬敮鎸侊紝浠庤屽彲浠ョ洿鎺ヨ漿鎹€傝繖涓仛娉曟槸鍙沖嚮宸ョ▼鍚嶁斻塒roperty鈥斻塆eneral涓殑character set涓夋嫨notset錛岃繖鏍鳳紝鏈枃寮澶寸殑閭f浠g爜灝卞彲浠ユ紜殑鎵ц浜嗐?/font>
濡備綍灝哘String杞崲涓篶har *鎴栬呯浉鍙?
How can I convert a QString to char* and vice versa ?(trolltech)
Answer:
In order to convert a QString to a char*, then you first need to get a latin1 representation of the string by calling toLatin1() on it which will return a QByteArray. Then call data() on the QByteArray to get a pointer to the data stored in the byte array. See the documentation:
See the following example for a demonstration:
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QString str1 = "Test";
QByteArray ba = str1.toLatin1();
const char *c_str2 = ba.data();
printf("str2: %s", c_str2);
return app.exec();
}
Note that it is necessary to store the bytearray before you call data() on it, a call like the following
const char *c_str2 = str2.toLatin1().data();
will make the application crash as the QByteArray has not been stored and hence no longer exists.
To convert a char* to a QString you can use the QString constructor that takes a QLatin1String, e.g:
QString string = QString(QLatin1String(c_str2)) ;
榪樻湁鍏朵粬澶氱鏂規硶錛?/p>
鏂規硶涓 -----------------------------------------
#define G2U(s) ( QTextCodec::codecForName("GBK")->toUnicode(s) )
#define U2G(s) ( QTextCodec::codecForName("GBK")->fromUnicode(s) )
QString str;
QCString cstr;
str = G2U("涓枃杈撳叆");
cstr = U2G(str);
QCString鏈夎繖鏍蜂竴涓噸杞借繍綆楃
operator const char * () const
鍙互榪欐牱
printf("%s\n", (const char*) cstr);
鎴栨槸copy鍑烘潵
char buf[1024];
strcpy(buf, (const char*) cstr);
鏂規硶浜?-----------------------------------------
濡傛灉鏄腑鏂囩郴緇?/p>
鐩存帴鐢?nbsp; (const char*) str.local8Bit()
渚嬪
printf("%s", (const char*) str.local8Bit());
str鏄竴涓猀String
鏂規硶涓?-----------------------------------------
char str[64];
QTextCodec *textcod = QTextCodec::codecForName("GBK");
QCString string1 = textcod ->fromUnicode(listbox1->currentText());
strcpy(str,string1);
QString鍜孲td::string
浠巆har*鍒?QString鍙互浠巉romLocal8Bit()杞寲
std::string鏈塩_str()鐨勫嚱鏁頒嬌鍐嶈漿鍖栦負char*
QString鏈塼oAscii()璁頒笉娓呬簡
浣犲彲浠ョ湅鐪?
鍙堟槸鎴戠殑綺楀績閰挎垚澶ч敊錛屾垜閲嶆柊鏌ョ湅浜嗕竴涓婹t鏂囨。錛屽師鏉t鍙互鐩存帴浠巗td::wstring浜х敓涓涓猀String錛岀敤QString::fromStdWString(const std::wstring &)榪欎釜闈欐佹垚鍛樺嚱鏁板嵆鍙傛垜璇曚簡璇曠敤std::string鐨刢_str()榪斿洖鐨刢har *鏋勯犵殑QString涓嶈兘鍐嶄繚瀛樺師鍏堢殑涓枃淇℃伅錛岃岀敤std::wstring鏋勯犵殑QString鍒欏彲浠ョ敤qDebug()杈撳嚭鍘熷厛鐨勪腑鏂囦俊鎭?
GB緙栫爜涓嶶TF8緙栫爜鐨勮漿鎹?br>鍦ㄤ富鍑芥暟app鍚庡姞涓婅繖鍙ワ細
QUOTE:
QTextCodec::setCodecForLocale(QTextCodec::codecForName("GB18030"));
鐒跺悗鏄粠UTF8緙栫爜鍒癎B緙栫爜鐨勫瓧絎︿覆杞崲鏂規硶錛?/p>
QUOTE:
QString Utf8_To_GB(QString strText)
{
return QString::fromUtf8(strText.toLocal8Bit().data());
}
鑷充簬浠嶨B鍒癠TF8錛岄偅澶у灝辯粡甯哥敤浜嗭細
QUOTE:
QString GB_To_Utf8(char *strText)
{
return QString::fromLocal8Bit(strText);
}