Hello
I am using QStringlist in one of my class which return the list to other class for the future use.
Qt Code:
  1. class test
  2. {
  3. QStringList test:: getDeviceInfoList()
  4. {
  5.  
  6. QStringList portList;
  7.  
  8.  
  9. if (numDevs > 0)
  10. {
  11. // allocate storage for list based on numDevs
  12. devInfo = (FT_DEVICE_LIST_INFO_NODE*)malloc(sizeof(FT_DEVICE_LIST_INFO_NODE)*numDevs);
  13.  
  14. // get the device information list
  15. ftStatus = FT_GetDeviceInfoList(devInfo,&numDevs);
  16.  
  17. if (ftStatus == FT_OK)
  18. {
  19. for (int i = 0; i < numDevs; i++)
  20. {
  21.  
  22. portList.append(QString(devInfo[i].SerialNumber));
  23. }
  24. }
  25. return portList;
  26. }
  27.  
  28. }
  29. }
  30.  
  31. class test2
  32. {
  33. bool test2::connect()
  34. {
  35. bool serialPortResponding = false;
  36.  
  37. if (m_D2xxport->PortConfiguration( m_D2xxport->getDeviceInfoList().at(0).toStdString().c_str()));
  38. {
  39. serialPortResponding = true;
  40. }
  41. else
  42. {
  43. serialPortResponding = false;
  44.  
  45. }
  46.  
  47. return serialPortResponding;
  48.  
  49. }
  50. }
To copy to clipboard, switch view to plain text mode 
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
Qt Code:
  1. if (m_D2xxport->PortConfiguration( m_D2xxport->getDeviceInfoList().at(0).toStdString().c_str()));
To copy to clipboard, switch view to plain text mode 
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.