Hidden magic in QNetworkInterface::allInterfaces()?



  • On Windows: when my code (in a Qt console test app) calls

    @QList<QNetworkInterface> list = QNetworkInterface::allInterfaces();@

    the first entry I get is always the one for the ethernet cable adapter. This is true, even if I explicitly disable that one in the relevant control panel. This is a good thing.

    I see, in the Qt code, that ultimately the Windows function GetAdaptersInfo() is called to get the list of adapters.

    However, in another app (where I'm unable to use this Qt call, due to linking issues...), I get a list of adapters using that very same GetAdaptersInfo() function. However, in this context, when the ethernet cable adapter is disabled with the control panel, I do not see an entry for that adapter in the list I get back. Various searches on the web indicate that a disabled adapter will not appear in the list given by GetAdaptersInfo().

    Frankly, I'm stumped: my own non-Qt code doesn't give me disabled adapters, and this is consistent with the info on the web. But, looking at the results from my little Qt console program, I'm indeed seeing that disabled adapter.

    How can this be?


  • Lifetime Qt Champion

    Hi,

    Just a guess but it might be using a cache after the first call



  • That would make sense...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.