signed char*/unsigned char*/QString

在redhat9.0下使用Qt3.1.1,实现signed char*/unsigned char*向QString转换。

 网上找了很多方法,都不行,最后直接强制转换了,暂时没有发现错误。

char* p = "abc"; 
signed char* p1 = ( signed char* )p; 
unsigned char* p2 = ( unsigned char* )p; 
 
QString str( "" ); 
QString str1( "" ); 
QString str2( "" ); 
 
int i=0; 
while( p[i]!='\0' ) 
{ str+=p[i]; i++; }  
 
int j=0; 
while( p1[j]!='\0' ) 
{ str1+=p1[j]; j++; } 
 
int k=0; 
while( p2[k]!='\0' ) 
{ str2+=p2[k]; k++; }
 
textLabel1->setText( str );
textLabel2->setText( str1 ); 
textLabel3->setText( str2 ); 
 
// for( int i=0;i<3;i++ )// {// str = str + p[i];// } 

你可能感兴趣的:(Qt,Linux)