PDA

View Full Version : QFtp->get() traversing trewidget



LordQt
20th March 2008, 09:16
Hello friends,

I make a connection to a ftp server and there was 6 folder.

.
..
A
B
C
D
E
F

Then I use the command mdFtp->cd("E"); to go in one folder to see the files or whatever?
When I click on one item I can download them with the command:

mdFtp->get(mdTreewidget->currentItem()->text(0), mdfile);

How can I get all files in one specific folder at one Time??
I try it with this loop but no result:


for (int i=0; i< mdTreewidget->currentItem()->childCount(); i++)


Have anybody an idea???

jpn
20th March 2008, 10:25
That loop alone doesn't tell much how do you actually handle it. Every call to QFtp::get() schedules a command and returns associated unique identifier. Did you take this into account?

LordQt
20th March 2008, 10:44
Hello,

actualy I make this:


void MdFtpWindow::downThemAll() /button click Download
{
mdFtp->get(mdTreewidget->currentItem()->text(0), mdfile);

}

That means one download click per file and after I try this:



void MdFtpWindow::downThemAll() /button click Download
{


for (int i=0; i< mdTreewidget->currentItem()->childCount(); i++)
{

mdFtp->get(mdTreewidget->itemAt(0,i)->text(0), mdfile);

}

}

And it seems that I must always click the Download Button per File. It don´t loop or parse the files in the Folder and get them!!

any Idea???

jpn
20th March 2008, 11:54
Don't you think you should pass a different output file?

LordQt
20th March 2008, 12:02
What do you mean????

jpn
20th March 2008, 12:07
You are passing the same target device ("mdfile") to every get() request.

LordQt
20th March 2008, 14:25
Ok I think I have trouble with the index.

When I use mdftp->cd("myfolder");

How can I acces the files under myfolder???

How do I iterate them??

jpn
20th March 2008, 15:05
See QFtp::list(). You might also want to take a look at the FTP example shipped with Qt.

LordQt
20th March 2008, 15:23
Hello,

I think I got it:



QTreeWidgetItemIterator it(mdTreewidget);
while (*it) {
QMessageBox::information(this, tr("DebugMessage"),
tr("ItemText: %1 ")
.arg((*it)->text(0)));
++it;
}