Copying the content of int array to QString
Hi Friends
Help need to convert integer array To QString and emit the data to my slot
Code:
int a[10]={196,192,200,194,178,147,196,200,194,200};
I already tried this
Code:
char text[] = { '1', '2', '3', '4', '5', '\0' };
qDebug()<<string;
emit Send_Data_Array_to_form(string);
above snippet work perfectly. But when i send integer array to QString the Receiver slot not properly receive my data i don know why. help me to resolve this issue.
this is my receiver slot
Code:
void MainWindow
::Test_Array_Initialization(QString S_Data
) {
qDebug()<<"*****SIGNAL EMITED From My_signal_get_form1**********"<<endl;
qDebug()<<"data received"<<S_Data.size()<<S_Data;
}
Thanks in Advance.
Re: Copying the content of int array to QString
Hi, your working snippet is basically a C-String, and QString has a constructor that uses a C-String as source.
To convert your integer array use a loop, call QString::number() for each of the array elements and append the result to your string.
Ginsengelf
Re: Copying the content of int array to QString
For future, I recommend to use stl::vector (QVector) instead of typical array.