I am trying to build an app that's showing me multiple widgets about different resources on my machine. In the code i am using popen() to run a command and get its output, to display on my widget.
However, when i try to run it in debug mode, at the first occurence of popen the debugger stops, and the app acts as if it was launched without the debugger. It doesn't close, and a part code is not being run, and i can't figure out why without the debugger.
I am using Qt version 5.13.2. This is an example of what makes the debugger stop.
char s[500];
char cmd[20]="ifconfig ";
strcat(cmd,_currentNIC._nicName.toStdString().c_str());
strcat(cmd," ");
FILE* pip=popen(cmd,"r");
fgets(s,499,pip);
In the code i am using popen() to run a command and get its output, to display on my widget.
Since widget
suggest that you not only use Qt Creator as a IDE, but also yo use Qt framework, I would recommend you to use QProcess .
Qt is quite cool multi-platform framework so if you do not have to use system specific API you should avoid it.
ifconfig
.
You do not have to use command line tools to fetch such information.
Qt provides API to provide such information see QNetworkInterface
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.