查看完整版本: [-- 用QT设计FTP客户端时如何实现预览FTP服务器上的文件内容 --]

QTCN开发网 -> Qt基础编程 -> 用QT设计FTP客户端时如何实现预览FTP服务器上的文件内容 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

xyx2018 2018-01-20 14:35

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

如题  远程服务器文件和目录显示在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;
    }
    }
用这个代码只能显示本地工程目录下的文件内容。远程服务器的该如何显示。代码什么样的  请求帮助。

alvinlyb 2018-01-23 14:02
我也想知道。请问你使用的是那个ftp接口?

夜雨触花 2018-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.



xyx2018 2018-01-25 16:20
夜雨触花:使用get()获取内容后再显示呗,dev赋值为0,定义一个绑定readyRead()信号的槽函数用于将内容显示出来。
 (2018-01-23 15:10) 

然后再删除掉 对吧  我试一下

xyx2018 2018-01-25 16:21
alvinlyb:我也想知道。请问你使用的是那个ftp接口? (2018-01-23 14:02) 

接口  是指  端口吗  21

alvinlyb 2018-03-14 11:16
xyx2018:接口  是指  端口吗  21 (2018-01-25 16:21) 

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

stlcours 2018-03-14 17:19
用POCO带的FTP,不要用QFTP 太弱了


查看完整版本: [-- 用QT设计FTP客户端时如何实现预览FTP服务器上的文件内容 --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Gzip disabled