////////////////cfrmmain.h
class frmMainWindow
:public QMainWindow,
public Ui
::MainWindow {
Q_OBJECT
public:
frmMainWindow();
private:
private slots:
void btnStartClicked();
void ftpListInfo
(const QUrlInfo &urlInfo
);
void ftpCommandFinished(int commandId, bool error);
void updateDataTransferProgress(qint64 readBytes,qint64 totalBytes);
};
/////////////////cfrmmain.cpp/////////
frmMainWindow::frmMainWindow()
{
setupUi(this);
connect(startSCP,SIGNAL(clicked()),this ,SLOT(btnStartClicked()));
ftp=0;
}
void frmMainWindow::btnStartClicked()
{
if (ftp) {
ftp->abort();
ftp->deleteLater();
ftp = 0;
return;
}
connect(ftp, SIGNAL(commandFinished(int, bool)),
this, SLOT(ftpCommandFinished(int, bool)));
connect(ftp,
SIGNAL(listInfo
(const QUrlInfo &)),
this,
SLOT(ftpListInfo
(const QUrlInfo &)));
connect(ftp, SIGNAL(dataTransferProgress(qint64, qint64)),
this, SLOT(updateDataTransferProgress(qint64, qint64)));
ftp->connectToHost("ftp.trolltech.com");
ftp->login();
ftp->list();
}
[COLOR="Red"]/////////////////all the SLOT function cannot performed ,why????????[/COLOR]
void frmMainWindow::ftpCommandFinished(int, bool error)
{
if (ftp
->currentCommand
() == QFtp::ConnectToHost) { if (error) {
tr("Unable to connect to the FTP server "
"at %1. Please check that the host "
"name is correct.")
.arg("192.168.1.3"));
return;
}
return;
}
if (ftp
->currentCommand
() == QFtp::Get) {
}
if (ftp
->currentCommand
() == QFtp::List) {
}
if (ftp
->currentCommand
() == QFtp::Put) {
}
}
void frmMainWindow::updateDataTransferProgress(qint64 readBytes,
qint64 totalBytes)
{
void frmMainWindow
::ftpListInfo(const QUrlInfo &urlInfo
) {
fileList<<urlInfo.name() ;
}
////////////////cfrmmain.h
class frmMainWindow:public QMainWindow,public Ui::MainWindow
{
Q_OBJECT
public:
frmMainWindow();
private:
QFtp *ftp; //连接FTP
QFile *file;
QStringList fileList;
private slots:
void btnStartClicked();
void ftpListInfo(const QUrlInfo &urlInfo);
void ftpCommandFinished(int commandId, bool error);
void updateDataTransferProgress(qint64 readBytes,qint64 totalBytes);
};
/////////////////cfrmmain.cpp/////////
frmMainWindow::frmMainWindow()
{
setupUi(this);
connect(startSCP,SIGNAL(clicked()),this ,SLOT(btnStartClicked()));
ftp=0;
}
void frmMainWindow::btnStartClicked()
{
if (ftp) {
ftp->abort();
ftp->deleteLater();
ftp = 0;
return;
}
ftp = new QFtp;
connect(ftp, SIGNAL(commandFinished(int, bool)),
this, SLOT(ftpCommandFinished(int, bool)));
connect(ftp, SIGNAL(listInfo(const QUrlInfo &)),
this, SLOT(ftpListInfo(const QUrlInfo &)));
connect(ftp, SIGNAL(dataTransferProgress(qint64, qint64)),
this, SLOT(updateDataTransferProgress(qint64, qint64)));
ftp->connectToHost("ftp.trolltech.com");
ftp->login();
ftp->list();
}
[COLOR="Red"]/////////////////all the SLOT function cannot performed ,why????????[/COLOR]
void frmMainWindow::ftpCommandFinished(int, bool error)
{
if (ftp->currentCommand() == QFtp::ConnectToHost) {
if (error) {
QMessageBox::information(0, tr("FTP"),
tr("Unable to connect to the FTP server "
"at %1. Please check that the host "
"name is correct.")
.arg("192.168.1.3"));
return;
}
return;
}
if (ftp->currentCommand() == QFtp::Get) {
}
if (ftp->currentCommand() == QFtp::List) {
QMessageBox::information(0, tr("FTP"),"LIST");
}
if (ftp->currentCommand() == QFtp::Put) {
}
}
void frmMainWindow::updateDataTransferProgress(qint64 readBytes,
qint64 totalBytes)
{
void frmMainWindow::ftpListInfo(const QUrlInfo &urlInfo)
{
fileList<<urlInfo.name() ;
}
To copy to clipboard, switch view to plain text mode
Bookmarks