gpt4 book ai didi

c++ - Qt5.2 NetworkManager::networkInterfaces()

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:58:10 26 4
gpt4 key购买 nike

我正在尝试编译一个简单的 Qt5.2 程序,它使用 libnm-qt5 和 libmm-qt5 来管理连接,但是当我试图用这段代码列出它们时:

#include <arpa/inet.h>

#include <QtCore/QTextStream>

#include <NetworkManagerQt5/manager.h>
#include <NetworkManagerQt5/device.h>
#include <NetworkManagerQt5/activeconnection.h>
#include <NetworkManagerQt5/connection.h>

QString typeAsString(const int type)
{
switch (type) {
case 0x0: return QString("Unknown");
case 0x1: return QString("Ethernet");
case 0x2: return QString("Wifi");
case 0x3: return QString("Unused1");
case 0x4: return QString("Unused2");
case 0x5: return QString("Bluetooth");
case 0x6: return QString("OlpcMesh");
case 0x7: return QString("Wimax");
case 0x8: return QString("Modem");
}
return QString("Unknown");
}

int main()
{
QTextStream qout(stdout, QIODevice::WriteOnly);

NetworkManager::Device::List list = NetworkManager::networkInterfaces();

foreach (NetworkManager::Device *dev, list) {
qout << dev->uni() << "\n";

我在 QtCreator 中遇到错误:“/home/me/Qt/5.2.1/gcc_64/include/QtCore/qglobal.h:860: error: cannot convert 'const QSharedPointer' to 'NetworkManager::Device* ' 在初始化中 for (variable = *container.i;; extension ({--container.brk; break;})) ^”

我一直在像 tis 这样的存储库中搜索:https://build.merproject.org/package/view_file?file=enable-contour.patch&package=plasma-mobile&project=home%3Awonko%3Apa-devel-contour-hack&rev=21他们使用:

NetworkManager::Device::List iflist = NetworkManager::networkInterfaces();
foreach (NetworkManager::Device::Ptr iface, iflist){

}

但它也给我错误。有谁知道正确的解决方案?

谢谢。

最佳答案

尝试替换

foreach (NetworkManager::Device *dev, list) { ... 

用这个:

foreach (NetworkManager::Device::ptr dev, list) { ...

关于c++ - Qt5.2 NetworkManager::networkInterfaces(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23574583/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com