qt 实现的wifi客户端STA和热点AP功能开发,qml做UI,C++实现功能,wifi操作都在线程里面。基于全志芯片T527 wifimg库实现,Tina平台,AllWinner软件平台

AgenticCoding·十二月创作之星挑战赛 10w+人浏览 410人参与

STA 功能:

   1、打开wifi。  开关防止误按做了长按处理,原本组件按一下就打开或者关闭,可是wifi耗时,,防止误按以及重复按,重新做了开关组件,长按时间可设置。

   2、搜索wifi列表   后台线程服务内搜索附近的wifi,并获得wifi信息传给UI,C++ 继承class WifiDataModel : public QAbstractListModel 实现

    3、连接WiFi    连接后wifi移到第一个,显示已连接, 操作model实现

    4、关闭WiFi 

所有wifi操作都在线程内,UI 层面不会有卡顿, 所有结果都是线程返回,  不是UI上操作后就显示结果,  操作后等待线程返回 更新UI结果界面。

#ifndef WIFIDATAMODEL_H
#define WIFIDATAMODEL_H

#include <QAbstractListModel>
#include <QObject>
#include <QList>
#include <QDebug>

#include "wifidataitem.h"

class WifiDataModel : public QAbstractListModel
{
    Q_OBJECT

public:
    enum Roles {
        NameRole = Qt::UserRole + 1,
        PaswdRole,
        SecurityRole,
        SecRole,
        LevelRole,
        ConnectRole
    };

    explicit WifiDataModel(QObject *parent = nullptr);
    ~WifiDataModel();

    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    QVariant data(const QModelIndex &index, int role) const override;
    QHash<int, QByteArray> roleNames() const override;

    Q_INVOKABLE bool addWifiItemData(const QString &ssid, const QString &security, const int &sec, const int &signalevel);
    Q_INVOKABLE bool addAllScanResault();
    Q_INVOKABLE bool removeAllScanResault();

    Q_INVOKABLE bool removeWifiItemData(int index);
signals:
    void notifyConnectRet(int ret);

private:
    QList<WifiDataItem> m_items;
};

#endif // WIFIDATAMODEL_H
    WifiDataModel{
        id:wfModel
    }

    Rectangle{
        anchors.top: netTitle.bottom
        anchors.topMargin: 12
        anchors.left: upline.left
        width: 862
        height: 200
        radius: 5
        color: "#E7E7E6"

        ListView {
            id: listView
            clip: true
            anchors.fill: parent
            model: wfModel

            ScrollBar.vertical: ScrollBar{
                anchors.right: parent.right
                policy: ScrollBar.AsNeeded
                background: Rectangle{
                    color: "#f0f0f0"
                    radius: 3
                }
            }

            delegate: Rectangle {
                width: listView.width
                height: 50
                RowLayout {
                }
            }
        }


    }

AP 功能:

1、打开热点   使用配置文件配置热点名字和密码

2、关闭热点

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值