How do I get phone info in QT? (carrier, device mo

2019-09-08 04:05发布

问题:

I've found something like below on the net

//Get S60 version and display it on label
switch (QSysInfo::s60Version ())
{
    case QSysInfo::SV_S60_3_1: return "S60 version: S60 3.1";
    case QSysInfo::SV_S60_3_2: return "S60 version: S60 3.2";
    case QSysInfo::SV_S60_5_0: return "S60 version: S60 5.0";
    case QSysInfo::SV_S60_Unknown: return "S60 version: S60 Unknown";
    default:
    break;
}

//Get OS version and display it on label
switch (QSysInfo::symbianVersion ())
{
    case QSysInfo::QSysInfo::SV_9_2: return "Symbian OS version: 9.2";
    case QSysInfo::SV_9_3: return "Symbian OS version: 9.3";
    case QSysInfo::SV_9_4: return "Symbian OS version: 9.4";
    case QSysInfo::SV_Unknown: return "Symbian OS version: Unknown";
    default:
    break;
}

BUT this doesn't compile as the QSysInfo class doesn't have s60Version method nor the symbian Version - I only get windowsVersion...

回答1:

Ok, found it - for everybody that needs that stuff:

QString carrierName = QSystemNetworkInfo::networkName(QSystemNetworkInfo::GsmMode);

QtMobility::QSystemDeviceInfo* d = new QtMobility::QSystemDeviceInfo(this);
QString imei = d->imei();
QString manufacturer = d->manufacturer();
QString model = d->model();
delete d;

QtMobility::QSystemInfo* s = new QtMobility::QSystemInfo(this);
QString osVer = s->version(QSystemInfo::Os);
delete s;

hope this helps someone :) cheers!