PDA

View Full Version : Qt QSystemNetworkInfo cellIdChanged(int) not emitting in device



akarthik10
1st November 2011, 08:41
Hello,
I'm trying to make a Qt program that calls a function whenever network CellId changes.

Here is my class declaration (I've not shown some members out of the scope of the question):


class Mgr:public QObject{
Q_OBJECT
public slots:
void onCidChange(int cell);
void NetworkStrengthChange(QSystemNetworkInfo::NetworkM ode mode,int i);
public:QString mcc,mnc,cid,lac;
QSystemNetworkInfo* networkInfo;
Mgr();
};
In the constructor:


networkInfo = new QSystemNetworkInfo();
mcc = networkInfo->currentMobileCountryCode();
qDebug()<<mcc; //I Get a proper debug output
mnc = networkInfo->currentMobileNetworkCode();
lac = QString::number(networkInfo->locationAreaCode());
cid = QString::number(networkInfo->cellId());
set("mccvar",mcc); //set(QString,QString) is my own method to display information, and it works
set("mncvar",mnc);
set("lacvar",lac);
set("cidvar",cid);

In the main function,


Mgr ob;
QObject::connect(ob.networkInfo, SIGNAL(cellIdChanged(int)), &ob, SLOT(onCidChange(int))); //The slot is never called even if cellid changes on device, but works on simulator
QObject::connect(ob.networkInfo, SIGNAL(networkSignalStrengthChanged(QSystemNetwork Info::NetworkMode,int)),&ob,SLOT(NetworkStrengthChange(QSystemNetworkInfo:: NetworkMode,int))); //Works great

and, i get to see the NetworkSignal dynamically, i mean if signal is 60% this second it shows 60 (Through my set() method) if it is 90% the very next second it shows 90 instantly.
This works in both Qt simulator and my device as well. (As the slot definition updates display value on Network Strength change)

But when it comes to cellid, the cellid shows at the time the object was constructed
and it remains there forever, even if i move my phone to a different location with different cellid(verified by another application), it remains the one which was during object construct. But this works well in Qt simulator, if I change the cellid, the slot gets called. I also tried to set again the new cellid value like set("cidvar",newcidvalue) inside the slot definition, which i think is necessary. But the slot never gets called in device, but it works in Qt simulator as said earlier.
So could someone help me where i am wrong, or alternative methods to detect the change in cellid ?

Final thing, i have moc'ed as the class involves Q_OBJECT