having some trouble getting QFtp object to connect...
I have private class members:
QLineEdit *ftpServerLineEdit;
QLineEdit *ftpUserLineEdit;
QLineEdit *ftpPasswordLineEdit;
QFtp *ftp;
QGraphicsView *internet;
To copy to clipboard, switch view to plain text mode
but can't get a QPushbuttons connect private slot function to work with this:
void MainWindow::testConnect(){
QString server
= ftpServerLineEdit
->text
();
QString user
= ftpUserLineEdit
->text
();
QString password
= ftpPasswordLineEdit
->text
();
if (!url.isValid() || url.scheme().toLower != QLatinString("ftp")){
ftp->connectToHost(server,21);
ftp->login(user, password);
if (ftp
->state
() == QFtp::LoggedIn){ internet
->setStyleSheet
(QString("background: url(:/images/Online.png);"));
}
else{
internet
->setStyleSheet
(QString("background: url(:/images/Offline.png);"));
}
}
} //end member function
void MainWindow::testConnect(){
ftp = new QFtp(this);
QString server = ftpServerLineEdit->text();
QString user = ftpUserLineEdit->text();
QString password = ftpPasswordLineEdit->text();
QUrl url(server);
if (!url.isValid() || url.scheme().toLower != QLatinString("ftp")){
ftp->connectToHost(server,21);
ftp->login(user, password);
if (ftp->state() == QFtp::LoggedIn){
internet->setStyleSheet(QString("background: url(:/images/Online.png);"));
}
else{
internet->setStyleSheet(QString("background: url(:/images/Offline.png);"));
}
}
} //end member function
To copy to clipboard, switch view to plain text mode
this never goes through the last if when I know that the hostname, username, & password are correct... can anyone help me with this? I'm sifting through the ftp example.... Is this code not getting a response from the server? therefore, just going to the last if, and then it's always false?
Bookmarks