Qt 5 to 6 and bearer management
-
Now that bearer management has been removed in Qt 6, I would like to build my Qt 5 application with
QNetworkAccessManager
(aka QNAM) but WITHOUT the things that have been removed in Qt 6. It seems that if I just use QNAM functions, the bearer stuff is automatically added to my configuration.I have read that e.g. on a Windows deployment, one could just remove the bearer DLL to do away with it, but this doesn't strike me as being a clean solution. Is there a CONFIG option or DEFINE symbol in
qmake
to make it go away?Thank you!
-
Why? To save 45kb by not deploying the qgenericbearer plugin?
-
@Christian-Ehrlicher No ... I want to leave my application in a usable state when I am no longer maintaining it, and the new people want to upgrade to Qt 6. I have already taken out QXmlPatterns and replaced this with Xerces, for example, for XML schema validation.
So I ask again: how do I do this cleanly (i.e. eliminate bearer, QNetworkSession, etc.)?
-
@Robert-Hairgrove said in Qt 5 to 6 and bearer management:
how do I do this cleanly (i.e. eliminate bearer, QNetworkSession, etc.)?
Take a look which classes are no longer available in Qt6 (by e.g. compiling it with Qt6), don't use them anymore and you're fine.
-
@Christian-Ehrlicher Thank you.
All I need is something to replace the
networkAccessibleChanged()
signal ofQNetworkAccessManager
; the rest should be OK.Unfortunately, I will have to wait a few days to see about installing Qt 6 (download server is unavailable right now). But I found this useful little program
showif.c
by Jon Mayo on the internet: https://gist.github.com/OrangeTide/909204. It is in the public domain, so I can adapt it for use on Linux easily enough.Now I have to find a Windows solution. However, there is probably a Windows API function that we can call. If anyone can point me in the right direction for something that works similar to Jon Mayo's function, that would be great!
-
You might take a look in the bearer plugin source code from Qt5 to get some inspiration.
-
In the meantime, I have been looking at
QTcpSocket
etc. It seems that I can create a socket and connect theQAbstractSocket::stateChanged()
signal to my slot which up till now was listening for the signalQNetworkAccessManager::networkAccessibleChanged()
.Are there any caveats to creating a TCP socket object for the same address as for sending GET/POST requests via QNAM? I really am getting into uncharted territory here since I never programmed with raw sockets before.