Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Can Qt WebKit detect specific network card
i have a specific network USB card (like USB 3G), but PC realize it like USB device. I want to send request to that device (then that device will send request to server itself). Say simply, i dont want request through network card, i'll catch request and send it to my device. How can i do? Sorrry if my question is confusing cuz my english is bad :(
anyone help me plz
Your OS needs to figure out the networking... Qt will just use what is configured there. My guess is that you will need to install some drivers for this to work.
Thanks Tobias for answer!
My device can transfer data (file, signal) go out to network well, but OS just realize it is a USB device, i want to use webbrowser with it, i think my work is just send request to it instead of ethernet card. I researched Qtwebkit, Qnetwork (Qnetworkaccsessmanager, Qnetworkrequest . ..) but haven't found the code that written for detecting network card. My idea is replacing networkcard by my device. Can i do?
WebKit is only for rendering websites; it does not understand network cards (which are also called Network Interface Controllers -- NICs)
You can query information about your computer's NICs using QNetworkInterface:
QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces();
for (int i = 0; i < interfaces.size(); ++i)
To use a non-default NIC, you need to find the QNetworkConfiguration associated with your NIC. You can list all your computer's configurations like this:
QList<QNetworkConfiguration> configs = configManager.allConfigurations();
for (int i = 0; i < configs.size(); ++i)
When you have found the configuration you want, make a QNetworkAccessManager use that configuration. Then, you can sent HTTP get/post requests through that NIC:
QNetworkReply *reply = manager.get(request);
Read these for info on how to create a request and handle the reply:
You will need to install (or write) a driver which will tell your OS "hey, look here, this is a network card" and then all applications will be able to use it as such. This of course includes all Qt apps.
@JKSH, Tobias: thank you so much!!! Your methods are "my device is understood be a network card"
But such as i asked, i want my device to tell "hey, im not network card, but i can transfer request go to internet, transfer request to me, then don't care me, myself i'll encrypt it, then send it, return reply to u after receiving and decrypt reply, c'mon baby!". Is there any way to do that?
Ah, I think understand your issue now.
Qt depends on the Operating System (OS) to tell it which network cards are available. If the OS doesn't recognize a device as a network card, Qt won't try to treat it as a network card.
If you want Qt to use your device as a network card, you must make your Operating System think that it's a network card. So, like Tobias said, you to get (or write) a driver for it. After that, Qt can use it to do networking stuff.
Maybe the manufacturer already has a driver for it. What is the brand + model number of your device? Also, what is your operating system?
My device is made by myself and maybe call it be a mini PC, it has 1 port ethernet, 1 port USB. Thats why i dont want it to be a network card. My browser on PC will transfer/receive request/reply through my device by the way: open /dev/ttyUSB0 and read/write data from it
You are aware that there is network support available for USB? Just make your device announce that it supports that (if it is linux-based, then its setup is about as hard as using serial-over-USB) and your clients should set up a network interface as soon as it connects, pretty much like they are creating the serial port now.