Search code examples
qtqstringdword

Converting a DWORD value into a QString


I have the following method in QT:

QString getHDDSerial() {
  DWORD dwVolSerial;
  BOOL bIsRetrieved;
  bIsRetrieved = GetVolumeInformation(L"C:\\", NULL, NULL, &dwVolSerial, NULL, NULL, NULL, NULL);

  qDebug() << dwVolSerial;
  if (bIsRetrieved) {
      return dwVolSerial;
  } else {
      return "error";
  }
}

How can I return the dwVolSerial as a QString?


Solution

  • I was able to get it done with this:

    return QString::number(dwVolSerial);