Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Scanning WiFi with Qt & Linux
QtWS25 Last Chance

Scanning WiFi with Qt & Linux

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • darkstaringD Offline
    darkstaringD Offline
    darkstaring
    wrote on last edited by
    #1

    Hi, i wold like how to scan WiFi with QT... i try with QProcess and iwlist under linux...

    void MainWindow::on_scan_clicked()
    {
        ui->scan->setText("Scanning");
    
        QString output;
        QString devices_selezionato = ui->devices->currentText();
        qDebug() << "SELECTED -> " << devices_selezionato ;
        QProcess system;
        QString command_set = "ip link set dev "+devices_selezionato+" down && sleep 1 && ip link set dev "+devices_selezionato+" up && iwlist "+devices_selezionato+" scan | grep -E 'Address|ESSID' | cut -c21- | sed 's/Address\: //g' | sed 's/ESSID\://g' ";//| sed 's/\"//g'";
        //qDebug()<<command_set;
        system.start("/bin/sh -c \""+command_set+"\"");
        system.waitForFinished();
        output = (system.readAllStandardOutput());
        output = (output + system.readAllStandardError());
        qDebug()<<"TROVO QUESTE RETI"<<output;
    
        QStringList outputlist = output.split("\n");
    
       // ui->lista_reti->setStyleSheet("overflow: auto; color:red;");
    
        int i = 0;
        QString col0;
        QString col1;
    
        foreach(QString value, outputlist)
        {
            i++;
            //ui->lista_reti->setText(ui->lista_reti->text() + value.replace("\n", "").replace("\"", "") + "\n");
            QTreeWidgetItem * item = new QTreeWidgetItem();
            item->setTextAlignment(0,Qt::AlignVCenter);
            item->setTextAlignment(1,Qt::AlignHCenter);
    
    
            if(i%2) { col0 = value; }
            else { col1 = value;}
            if(! col0.isEmpty() && !col1.isEmpty())
            { item->setText(0,col0); item->setText(1,col1); ui->treeWidgetWiFis->addTopLevelItem(item); col0="";col1=""; }
    
            qDebug() << value;
        }
    }
    

    Exists a method for scan WiFi directly with QT ?

    Thanks Francesco

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      If you are thinking about a replacement of iwlist, there's none directly as it is outside the scope of Qt.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • darkstaringD Offline
        darkstaringD Offline
        darkstaring
        wrote on last edited by
        #3

        so I can not scan WiFi with Qt?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          The way you did it using QPorces seems good it this point.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • darkstaringD Offline
            darkstaringD Offline
            darkstaring
            wrote on last edited by
            #5

            thanks ;)....
            Francesco

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved