anh5kor
27th November 2014, 15:34
Hello
I am using QStringlist in one of my class which return the list to other class for the future use.
class test
{
QStringList test:: getDeviceInfoList()
{
QStringList portList;
if (numDevs > 0)
{
// allocate storage for list based on numDevs
devInfo = (FT_DEVICE_LIST_INFO_NODE*)malloc(sizeof(FT_DEVICE _LIST_INFO_NODE)*numDevs);
// get the device information list
ftStatus = FT_GetDeviceInfoList(devInfo,&numDevs);
if (ftStatus == FT_OK)
{
for (int i = 0; i < numDevs; i++)
{
portList.append(QString(devInfo[i].SerialNumber));
}
}
return portList;
}
}
}
class test2
{
bool test2::connect()
{
bool serialPortResponding = false;
if (m_D2xxport->PortConfiguration( m_D2xxport->getDeviceInfoList().at(0).toStdString().c_str()));
{
serialPortResponding = true;
}
else
{
serialPortResponding = false;
}
return serialPortResponding;
}
}
The above code works fine if my portList contain some data.Some time it happens my portList does not contain any data in the case i get runtime error
on position
if (m_D2xxport->PortConfiguration( m_D2xxport->getDeviceInfoList().at(0).toStdString().c_str()));
I want to send null if my portList is empty or if list is empty send null if full then send portList .
QStringlist always show compile time error if i send Null or 0.
I am using QStringlist in one of my class which return the list to other class for the future use.
class test
{
QStringList test:: getDeviceInfoList()
{
QStringList portList;
if (numDevs > 0)
{
// allocate storage for list based on numDevs
devInfo = (FT_DEVICE_LIST_INFO_NODE*)malloc(sizeof(FT_DEVICE _LIST_INFO_NODE)*numDevs);
// get the device information list
ftStatus = FT_GetDeviceInfoList(devInfo,&numDevs);
if (ftStatus == FT_OK)
{
for (int i = 0; i < numDevs; i++)
{
portList.append(QString(devInfo[i].SerialNumber));
}
}
return portList;
}
}
}
class test2
{
bool test2::connect()
{
bool serialPortResponding = false;
if (m_D2xxport->PortConfiguration( m_D2xxport->getDeviceInfoList().at(0).toStdString().c_str()));
{
serialPortResponding = true;
}
else
{
serialPortResponding = false;
}
return serialPortResponding;
}
}
The above code works fine if my portList contain some data.Some time it happens my portList does not contain any data in the case i get runtime error
on position
if (m_D2xxport->PortConfiguration( m_D2xxport->getDeviceInfoList().at(0).toStdString().c_str()));
I want to send null if my portList is empty or if list is empty send null if full then send portList .
QStringlist always show compile time error if i send Null or 0.