How to extract variable created in the function to the variable outside of the function?
-
I would like to extract one of my variable(headerbyte) that is stored in a function to be stored in a variable outside of this function.
QString headerbyte = ();
DataTable ThemeWidget::generateRandomData(const QByteArray &data) const
{
DataTable dataTable;
QByteArray testdata = data;
QString headerbyte = testdata.left(10);
testdata.remove(0,10);
// generate testdata
int listCount = 1;
for (int i(0); i < listCount; i++) {
DataList dataList;
float yValue(0);
int count(0);
QString datavalue;
QString checksign;
for (int j(0); j<136; j++)
{
testdata.remove(0,1);
checksign = testdata.left(1);
if (checksign == "-"){
datavalue = testdata.left(7);
testdata.remove(0,7);
}
else{
datavalue = testdata.left(6);
testdata.remove(0,6);
}
yValue = datavalue.toFloat();
QPointF value(count, yValue);
count++;
dataList << Data(value);
}
dataTable << dataList;
}
return dataTable;
}How do i go about doing it?
-
Hi,
Make your function return both e.g. through a structure or a tuple.
-
@jbbb said in How to extract variable created in the function to the variable outside of the function?:
any example?
Take a c++ book, read about classes. Nothing Qt-specific here, simple c++ basics. Sorry.