×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    Question How to see current QSystemNetworkInfo::NetworkMode?

    I'm trying to see the current QSystemNetworkInfo::NetworkMode. According to this link there is something called QSystemNetworkInfo::NetworkMode currentMode (), but it doesn't seem to exist in Qt Creator at least.

    Thanks

  2. #2
    Registered User
    Join Date
    Jun 2007
    Location
    Mumbai, India
    Posts
    1,998

    Re: How to see current QSystemNetworkInfo::NetworkMode?

    Check this example for usage

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    Re: How to see current QSystemNetworkInfo::NetworkMode?

    Well this is strange. I tried it in another computer and there it sees it fine. IN this computer I'm running the final version of Nokia Qt SDK, while the other one was running on the beta.

    Anyway, I have the following code:
    Code:
                QSystemNetworkInfo* networkInfo = new QSystemNetworkInfo();
                QSystemNetworkInfo::NetworkMode mode = networkInfo->currentMode();
                switch (mode) {
                case QSystemNetworkInfo::UnknownMode:
                    updated = "UnknownMode ";
                    break;
                case QSystemNetworkInfo::GsmMode:
                    updated = "GsmMode ";
                    break;
                case QSystemNetworkInfo::CdmaMode:
                    updated = "CdmaMode ";
                    break;
                case QSystemNetworkInfo::WcdmaMode:
                    updated = "WcdmaMode ";
                    break;
                case QSystemNetworkInfo::WlanMode:
                    updated = "WlanMode ";
                    break;
                case QSystemNetworkInfo::EthernetMode:
                    updated = "EthernetMode ";
                    break;
                case QSystemNetworkInfo::BluetoothMode:
                    updated = "BluetoothMode ";
                    break;
                case QSystemNetworkInfo::WimaxMode:
                    updated = "WimaxMode ";
                    break;
                }
    The problem is that I always get WcdmaMode. Am I doing something wrong here?

    Cheers

  4. #4
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: How to see current QSystemNetworkInfo::NetworkMode?

    What you probably want is networkStatus
    http://doc.qt.nokia.com/qtmobility-1...#networkStatus

  5. #5
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    Re: How to see current QSystemNetworkInfo::NetworkMode?

    Yes, that is what I want to see, but to be able to see that, I need to pass QSystemNetworkInfo::NetworkMode mode. So I need to find out that before. Or am I doing this all wrong?

  6. #6
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: How to see current QSystemNetworkInfo::NetworkMode?

    You can pass any mode to see if that's connected.

  7. #7
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    Re: How to see current QSystemNetworkInfo::NetworkMode?

    OK, I've tried it and that works. But if I don't know what mode is used, what should I do? Should I just try all the different modes? Isn't there a better way to find out?

    I'm currently using QMaemoInternetConnectivity::isConnected in my app. The problem with it, is that it returns true when it's still connecting.

  8. #8
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: How to see current QSystemNetworkInfo::NetworkMode?

    Sample code:
    Code:
        QSystemNetworkInfo* networkInfo = new QSystemNetworkInfo();
        for (int mode = QSystemNetworkInfo::UnknownMode;
             mode <= QSystemNetworkInfo::WimaxMode;
             mode++) {
            QString modeStr, statusStr;
            switch((QSystemNetworkInfo::NetworkMode)mode) {
            case QSystemNetworkInfo::UnknownMode:
                modeStr = "UnknownMode";
                break;
            case QSystemNetworkInfo::GsmMode:
                modeStr = "GsmMode";
                break;
            case QSystemNetworkInfo::CdmaMode:
                modeStr = "CdmaMode";
                break;
            case QSystemNetworkInfo::WcdmaMode:
                modeStr = "WcdmaMode";
                break;
            case QSystemNetworkInfo::WlanMode:
                modeStr = "WlanMode";
                break;
            case QSystemNetworkInfo::EthernetMode:
                modeStr = "EthernetMode";
                break;
            case QSystemNetworkInfo::BluetoothMode:
                modeStr = "BluetoothMode";
                break;
            case QSystemNetworkInfo::WimaxMode:
                modeStr = "WimaxMode";
                break;
            }
            switch(networkInfo->networkStatus((QSystemNetworkInfo::NetworkMode)mode)) {
            case QSystemNetworkInfo::UndefinedStatus:
                statusStr = "UndefinedStatus";
                break;
            case QSystemNetworkInfo::NoNetworkAvailable:
                statusStr = "NoNetworkAvailable";
                break;
            case QSystemNetworkInfo::EmergencyOnly:
                statusStr = "EmergencyOnly";
                break;
            case QSystemNetworkInfo::Searching:
                statusStr = "Searching";
                break;
            case QSystemNetworkInfo::Busy:
                statusStr = "Busy";
                break;
            case QSystemNetworkInfo::Connected:
                statusStr = "Connected";
                break;
            case QSystemNetworkInfo::HomeNetwork:
                statusStr = "HomeNetwork";
                break;
            case QSystemNetworkInfo::Denied:
                statusStr = "Denied";
                break;
            case QSystemNetworkInfo::Roaming:
                statusStr = "Roaming";
                break;
            }
            qDebug() << modeStr << statusStr;
        }
    Sample output:
    Code:
    "UnknownMode" "UndefinedStatus" 
    "GsmMode" "HomeNetwork" 
    "CdmaMode" "HomeNetwork" 
    "WcdmaMode" "HomeNetwork" 
    "WlanMode" "Connected" 
    "EthernetMode" "Connected" 
    "BluetoothMode" "UndefinedStatus" 
    "WimaxMode" "UndefinedStatus"

Similar Threads

  1. QSystemNetworkInfo hangs application
    By ceptad in forum [Archived] Qt Mobility Project
    Replies: 4
    Last Post: 2010-07-29, 15:03
  2. getting current date
    By vinayakak in forum Symbian
    Replies: 5
    Last Post: 2010-03-03, 12:26
  3. How can I get the current font color of current theme ?
    By nadis in forum Symbian Media (Closed)
    Replies: 5
    Last Post: 2009-05-08, 23:36
  4. How do we get current url?
    By deepak.mali in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2008-08-29, 02:59
  5. How do I know the current theme
    By cj.hust in forum Symbian
    Replies: 4
    Last Post: 2007-07-25, 07:37

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •