like the question,hope someone can give me the right answer.thanks~
like the question,hope someone can give me the right answer.thanks~
thanks for your answer.But it seems that there are some problems of my description.What I want to achieve is something like data analysis.This is the data analysis of my test source.
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QSize s(100 , 100);
QString str = "hello world";
QList<QGenericArgument> param;
param<<Q_ARG(QSize , s)<<Q_ARG(QString , str);
netWorkRemoteCall("netwrok" , "sendData" , param);
}
void MainWindow::netWorkRemoteCall(QString className, QString methodName, QList<QGenericArgument> param)
{
QByteArray data;
QStringList typeNames;
QDataStream stream(&data , QIODevice::WriteOnly);
stream<<className<<methodName;
for(int q = 0 ; q < param.size() ; q++)
{
typeNames<<param.at(q).name();
}
stream<<typeNames;
for(int i = 0 ; i < param.size() ; i++)
{
//stream<<param.at(i).name();
if(param.at(i).name() == "QString")
{
QString str = *(QString *)param.at(i).data();
stream<<str;
}
else if(param.at(i).name() == "QSize")
{
QSize size = *(QSize*)param.at(i).data();
stream<<size;
}
}
qDebug()<<data.size();
dataAnalysis(data);
}
void MainWindow::dataAnalysis(QByteArray data)
{
QByteArray datas = data;
qDebug()<<datas.size();
QDataStream stream(datas);
QString className;
QString methodName;
QStringList typeNames;
stream>>className>>methodName>>typeNames;
//qDebug()<<className<<methodName<<" "<<className.size() //+methodName.size();
for(int i = 0 ; i < typeNames.size() ; i++)
{
qDebug()<<typeNames.at(i);
if(typeNames.at(i) == "QString")
{
QString s;
stream>>s;
qDebug()<<s;
}
else if(typeNames.at(i) == "QSize")
{
QSize s;
stream>>s;
qDebug()<<s;
}
}
}
and I want to parse is the data like QVector<QStringList> , QPoint , QHash,QMap.I don't konw whether QDataStram support them.......
Bookmarks