Results 1 to 3 of 3

Thread: Detecting network type is 3G or Wifi

  1. #1
    Join Date
    Aug 2010
    Posts
    19
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo
    Wiki edits
    9

    Default Detecting network type is 3G or Wifi

    Hello,

    I would like my application to behave differently for Wifi and 3G network.
    The problem is that my application has to detect which network that QNetworkAccessManager is using.

    For Qt 4.7, QNetworkAccessManager has a method called configuration() which returned the configuration used for creating connection.
    If I want to do the same thing for Qt4.6, how do I do that? (4.6 does not have configuration method).

    Any idea aboyt this?

    Thank

    Hai

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Detecting network type is 3G or Wifi

    If Qt-4.7 already has this:
    http://qt.gitorious.org/qt

    You can look at the code of QNetworkAccessManager.

  3. The following user says thank you to tbscope for this useful post:

    lyhoanghai (26th August 2010)

  4. #3
    Join Date
    Aug 2010
    Posts
    19
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo
    Wiki edits
    9

    Default Re: Detecting network type is 3G or Wifi

    Thanks for your link.
    A quick look to QNetworkAccessManager.createRequest() shows that
    Qt Code:
    1. if (!d->networkSession && (d->initializeSession || !d->networkConfiguration.isEmpty())) {
    2.  
    3. 966
    4.  
    5. QNetworkConfigurationManager manager;
    6.  
    7. 967
    8.  
    9. if (!d->networkConfiguration.isEmpty()) {
    10.  
    11. 968
    12.  
    13. d->createSession(manager.configurationFromIdentifier(d->networkConfiguration));
    14.  
    15. 969
    16.  
    17. } else {
    18.  
    19. 970
    20.  
    21. if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired)
    22.  
    23. 971
    24.  
    25. d->createSession(manager.defaultConfiguration());
    26.  
    27. 972
    28.  
    29. else
    30.  
    31. 973
    32.  
    33. d->initializeSession = false;
    34.  
    35. 974
    36.  
    37. }
    38.  
    39. 975
    40.  
    41. }
    To copy to clipboard, switch view to plain text mode 

    Thus, QNetworkAccessManager use NetworkConfigurationManager.defaultConfiguration() .

Similar Threads

  1. Replies: 7
    Last Post: 19th April 2011, 12:20
  2. Replies: 2
    Last Post: 22nd December 2009, 20:52
  3. Detecting OS
    By ankit17.ag in forum Qt Programming
    Replies: 2
    Last Post: 16th July 2008, 10:10
  4. Type and User Type
    By campana in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2006, 23:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.