• 6003阅读
  • 6回复

用QT设计FTP客户端时如何实现预览FTP服务器上的文件内容 [复制链接]

上一主题 下一主题
离线xyx2018
 

只看楼主 倒序阅读 楼主  发表于: 2018-01-20
如题  远程服务器文件目录显示在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;
    }
    }
用这个代码只能显示本地工程目录下的文件内容。远程服务器的该如何显示。代码什么样的  请求帮助。
11111111111111
离线alvinlyb

只看该作者 1楼 发表于: 2018-01-23
我也想知道。请问你使用的是那个ftp接口?
离线夜雨触花

只看该作者 2楼 发表于: 2018-01-23
使用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.


4条评分好评度+1贡献值+1金钱+5威望+1
xyx2018 好评度 +1 - 2018-01-25
xyx2018 贡献值 +1 - 2018-01-25
xyx2018 威望 +1 - 2018-01-25
xyx2018 金钱 +5 - 2018-01-25
离线xyx2018

只看该作者 3楼 发表于: 2018-01-25
回 夜雨触花 的帖子
夜雨触花:使用get()获取内容后再显示呗,dev赋值为0,定义一个绑定readyRead()信号的槽函数用于将内容显示出来。
 (2018-01-23 15:10) 

然后再删除掉 对吧  我试一下
11111111111111
离线xyx2018

只看该作者 4楼 发表于: 2018-01-25
回 alvinlyb 的帖子
alvinlyb:我也想知道。请问你使用的是那个ftp接口? (2018-01-23 14:02) 

接口  是指  端口吗  21
11111111111111
离线alvinlyb

只看该作者 5楼 发表于: 2018-03-14
回 xyx2018 的帖子
xyx2018:接口  是指  端口吗  21 (2018-01-25 16:21) 

是那个库?新qt已没有qftp。还是用qftp吗?
离线stlcours

只看该作者 6楼 发表于: 2018-03-14
用POCO带的FTP,不要用QFTP 太弱了
快速回复
限100 字节
 
上一个 下一个