connect(ui->lineEdit_ftp_adr, SIGNAL(textEdited(QString)), SLOT(ftp_connect())); connect(ui->lineEdit_ftp_port, SIGNAL(textEdited(QString)), SLOT(ftp_connect())); connect(ui->lineEdit_ftp_user, SIGNAL(textEdited(QString)), SLOT(ftp_connect())); connect(ui->lineEdit_ftp_pass, SIGNAL(textEdited(QString)), SLOT(ftp_connect())); connect(&ftp, SIGNAL(commandFinished(int,bool)), this, SLOT(ftp_state(int, bool))); void MainWindow::ftp_connect(){ ftp.connectToHost(ui->lineEdit_ftp_adr->text().simplified(), ui->lineEdit_ftp_port->text().toInt()); ftp.login(ui->lineEdit_ftp_user->text().simplified(), ui->label_ftp_pass->text().simplified()); qDebug() << ftp.error();}void MainWindow::ftp_state(int, bool error){ if(error) { qDebug() << "Не могу подключиться к ftp-серверу"; } else { qDebug() << "OK"; }}
0Не могу подключиться к ftp-серверу3Не могу подключиться к ftp-серверу3Не могу подключиться к ftp-серверу3Не могу подключиться к ftp-серверу //последний вызов, дальше тока qDebug() << ftp.error() показывает2000000
connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(ftp_connect())); connect(&ftp, SIGNAL(commandFinished(int,bool)), this, SLOT(ftp_state(int, bool)));void MainWindow::ftp_connect(){ ftp.connectToHost(ui->lineEdit_ftp_adr->text().simplified(), ui->lineEdit_ftp_port->text().toInt()); ftp.login(ui->lineEdit_ftp_user->text().simplified(), ui->label_ftp_pass->text().simplified());}void MainWindow::ftp_state(int, bool error){ if (ftp.currentCommand() == QFtp::ConnectToHost) { if(!error) { qDebug() << "Соединение с хостом установлено"; } qDebug() << ftp.errorString(); }}
"Unknown error"QAbstractSocket::connectToHost() called when already looking up or connecting/connected to "192.168.1.1"
void MainWindow::ftp_connect2(){ QUrl url("ftp://" + ui->lineEdit_ftp_adr->text().simplified() + "/1"); url.setPort(ui->lineEdit_ftp_port->text().toInt()); url.setUserName(ui->lineEdit_ftp_user->text().simplified()); url.setPassword(ui->lineEdit_ftp_pass->text().simplified()); QNetworkRequest request(url); QNetworkAccessManager *manager = new QNetworkAccessManager; QNetworkReply *reply = manager->get(request); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(finishedSlot(QNetworkReply::NetworkError)));}void MainWindow::finishedSlot(QNetworkReply::NetworkError networkError){ qDebug()<< networkError;}