所以QFtp
被删除了,因为他们说的设计很糟糕。随你。
但是,对于新应用程序,建议使用 QNetworkAccessManager和QNetworkReply,因为那些类拥有一个 更简单,更强大的API。 (来自 docs )
我抬头QNetworkAccessManager
,这让人感到困惑。它不是套接字,甚至似乎不提供原始套接字方法。但它也不是FTP。它提供与HTTP相关的功能,如cookieJar
,post
,get
...有人可以提醒我FTP如何响应HTTP数据吗?
所以这个问题由两部分组成:
我当然找到了一些代码,我现在正试图让它起作用,但真正的问题是它对我来说毫无意义。
答案 0 :(得分:2)
Current FTP back-end of QNetworkAccessManager
implements get()
and put()
operations. So, it should be enough to download or to upload files using FTP protocol.
The protocol used by QNetworkAccessManager
is defined by URL scheme.
So, for FTP URLs ("ftp://..."), the functions get()
or put()
create connection using FTP protocol.
Username and password are taken from QUrl::userName()
and QUrl::password()
.
So, the key words in the docs are "a simpler API". It is not needed to execute manually connect
, login
, cd
and get
commands. Thus, it is not needed to implement own state machine to manage many FTP states in asynchronous application as it was before with QFtp
QNetworkAccessManager
provides much simpler API for downloading/uploading files.
For other FTP commands some external module should be used like Qt Ftp
.