×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Regular Contributor
    Join Date
    Dec 2010
    Posts
    55

    diplaying address enteries in qnetworkinterface

    hi there,

    i want to dipslay these ip addresses ,the braodcast and netmask on the screen.....i used the following to obatin the info
    but i cant seem to get it on the screen

    QList<QNetworkAddressEntry> entries;
    entries = inter->addressEntries();

    can smbdy plz tel me how to.....
    i mean what command to use in a for loop?
    thank u

  2. #2
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: diplaying address enteries in qnetworkinterface

    Use qDebug for CLI and QListWidget for GUI.

  3. #3
    Regular Contributor
    Join Date
    Dec 2010
    Posts
    55

    Re: diplaying address enteries in qnetworkinterface

    yup ..i was trying to use Qlist widget...here is what i was trying to do...bt it gives an error : invalid use of operator "="


    item->addItem( QString("Address entries:") );
    for (int i = 0; i < entries.size(); ++i)
    {
    str = entries.at(i).broadcast(); // Show the IP address
    item->addItem(str);
    }
    cn u plz guide me wat to do now?

  4. #4

  5. #5
    Regular Contributor
    Join Date
    Dec 2010
    Posts
    55

    Re: diplaying address enteries in qnetworkinterface

    Quote Originally Posted by rabeeah View Post
    item->addItem( QString("Address entries:") );
    for (int i = 0; i < entries.size(); ++i)
    {
    str = entries.at(i).broadcast(); // Show the IP address
    item->addItem(str);
    }
    sorry m probably nt following u on ths list problem...

    in the code above.. str is of type Qstring and item of QListWidget... and the last statement add item allows only a string or a QListWidgetItem

    now if i continue to use the above program, it gives me the following error

    error: no match for 'operator=' in 'str = entries.QList<T>::at [with T = QNetworkAddressEntry](i)'

    & if i use a QListWidgetItem for the str statement , it says the following..

    error: cannot convert 'const QNetworkAddressEntry' to 'QListWidgetItem*' in assignment

    m still nt clear wat to do....

  6. #6
    Regular Contributor
    Join Date
    Dec 2010
    Posts
    55

    Re: diplaying address enteries in qnetworkinterface

    ok i tried the qDebug command....the address entries are being shown as a console output now...
    i used the following commands:
    for (int i = 0; i < listInterNames.size(); ++i)
    {
    qDebug()<< listInterNames.at(i).addressEntries().at(i).ip()<<endl;
    qDebug()<< listInterNames.at(i).addressEntries().at(i).broadcast()<<endl;

    qDebug()<< listInterNames.at(i).addressEntries().at(i).netmask()<<endl;

    }

    this gives the following output,..(the ip, broadcast, netmask for one interface only...i.e...the loop executes once and then gives an error)
    QHostAddress( "192.168.11.195" )

    QHostAddress( "192.168.11.255" )

    QHostAddress( "255.255.252.0" )

    ASSERT failure in QList<T>::at: "index out of range", file ..\..\..\NokiaQtSDK\Simulator\Qt\mingw\include/QtCore/qlist.h, line 455

    can u plz point out the mistake in this , v'd b highly grateful.

  7. #7
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: diplaying address enteries in qnetworkinterface

    You have to use nested loop to print addressEntries list. I wonder how you produced listInterNames.

  8. #8
    Regular Contributor
    Join Date
    Dec 2010
    Posts
    55

    Re: diplaying address enteries in qnetworkinterface

    rite....thanks.....

    the listinternames is workin fine with one loop....this is how i used it..

    inter=new QNetworkInterface();
    QList<QNetworkInterface> listInterNames;
    QString str;


    listInterNames = inter->allInterfaces();
    listIpAddrs = inter->allAddresses();

    // the names
    item->addItem( QString("Interface names:") );
    for (int i = 0; i < listInterNames.size(); ++i)
    {
    str = listInterNames.at(i).humanReadableName();
    item->addItem(str);

    }

  9. #9
    Regular Contributor
    Join Date
    Dec 2010
    Posts
    55

    Re: diplaying address enteries in qnetworkinterface

    well...i tried using nested loops for it......of what i understand, .the idea is to choose the ith interface from the listInterNames list and then use the j variable to print the broadcast, ip, & the netmask...
    rite?.....

    but i dn understand how do i do that....i mean ..how do i restructure "qDebug()<< listInterNames.at(i).addressEntries().at(i).ip()<<endl;" for two variables?

  10. #10
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: diplaying address enteries in qnetworkinterface

    This is how one could do a nested loop
    Code:
    QList<QList> listOfLists;
    for (int i = 0; i < listOfLists.size(); ++i) {
      QList<Item> list = listOfLists.at(i);
      for (int j = 0; j < list.size(); ++j) {
        Item item = list.at(j);
      }
    }

  11. #11
    Regular Contributor
    Join Date
    Dec 2010
    Posts
    55

    Re: diplaying address enteries in qnetworkinterface

    dat workd!!....thanks a lot

Similar Threads

  1. Replies: 8
    Last Post: 2010-08-31, 12:29
  2. Getting and setting MAC address, Subnet Mask Address
    By Blackhawk255 in forum Symbian
    Replies: 22
    Last Post: 2008-10-17, 02:18
  3. Problem in getting Address from address book
    By Nemat in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2008-06-24, 08:22
  4. Can i send a address from server to client address
    By chinazou305 in forum Symbian
    Replies: 2
    Last Post: 2003-11-28, 03:56

Posting Permissions

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