首页| 论坛| 消息

标题:用QT设计FTP客户端时如何实现预览FTP服务器上的文件内容
作者:xyx2018
日期:2018-01-20 14:35
内容:

如题远程服务器文件和目录显示在treewidget里面。如何获取里面文件内容显示在textedit上 。
if(!clientIsDir.value(str))
{
name=new QFile(str);
bool ok=name->open(QIODevice::ReadOnly);
if(ok)
{
QTextStream in(name);
TextEidt->setText(in.readAll());
name->close();
delete name;
}
}
用这个代码只能显示本地工程目录下的文件内容。远程服务器的该如何显示。代码什么样的请求帮助。


#1 [alvinlyb 01-23 14:02]
我也想知道。请问你使用的是那个ftp接口?
#2 [夜雨触花 01-23 15:10]
使用get()获取内容后再显示呗,dev赋值为0,定义一个绑定readyRead()信号的槽函数用于将内容显示出来。
int QFtp::get ( const QString & file, QIODevice * dev = 0, TransferType type = Binary )
Downloads the file file from the server.
If dev is 0, then the readyRead() signal is emitted when there is data available to read. You can then read the data with the read() or readAll() functions.
For example, if you want to present the data to the user as soon as there is something available, connect to the readyRead() signal and read the data immediately......
The data is transferred as Binary or Ascii depending on the value of type.
#3 回 夜雨触花 的帖子 [xyx2018 01-25 16:20]
夜雨触花:使用get()获取内容后再显示呗,dev赋值为0,定义一个绑定readyRead()信号的槽函数用于将内容显示出来。

 (2018-01-23 15:10) 
然后再删除掉 对吧我试一下
#4 回 alvinlyb 的帖子 [xyx2018 01-25 16:21]
alvinlyb:我也想知道。请问你使用的是那个ftp接口? (2018-01-23 14:02) 
接口是指端口吗21
#5 回 xyx2018 的帖子 [alvinlyb 03-14 11:16]
xyx2018:接口  是指  端口吗  21 (2018-01-25 16:21) 
是那个库?新qt已没有qftp。还是用qftp吗?

<< 1 2 >> (1/2)

回复 发表
主题 版块