Russian Qt Forum
Сентябрь 30, 2024, 10:18 *
Добро пожаловать, Гость. Пожалуйста, войдите или зарегистрируйтесь.
Вам не пришло письмо с кодом активации?

Войти
 
  Начало   Форум  WIKI (Вики)FAQ Помощь Поиск Войти Регистрация  

Страниц: [1]   Вниз
  Печать  
Автор Тема: QFtp сигнал done  (Прочитано 3073 раз)
B_u_R_n
Гость
« : Апрель 19, 2010, 17:55 »

Проблема такова, вот кусок кода:
    ftp = new QFtp(this);
    ftp1= new QFtp(this);
    connect(ftp, SIGNAL(commandFinished(int,bool)),this, SLOT(ftpCommandFinished(int,bool)));
    connect(ftp, SIGNAL(listInfo(QUrlInfo)),this, SLOT(addToList(QUrlInfo)));
    connect(ftp, SIGNAL(dataTransferProgress(qint64,qint64)),this, SLOT(updateDataTransferProgress(qint64,qint64)));
    connect(ftp1, SIGNAL(dataTransferProgress(qint64,qint64)),this, SLOT(updateDataTransferProgress(qint64,qint64)));
    connect(ftp1, SIGNAL(done(bool)), this, SLOT(ftpDone(bool)));
    connect(ftp1, SIGNAL(listInfo(QUrlInfo)),this, SLOT(ftpListInfo(const QUrlInfo &)));
Стоят обработчики в обработчике на кнопку конект по фтп, после идет конект только на 1 фтп, а именно
fileList->clear();
    currentPath.clear();
    isDirectory.clear();
    QUrl url(ftpServerLineEdit->text());
    if (!url.isValid() || url.scheme().toLower() != QLatin1String("ftp"))
    {
        ftp->connectToHost(ftpServerLineEdit->text(), 21);
        ftp->login();

    }
    else
    {
        ftp->connectToHost(url.host(), url.port(21));

        if (!url.userName().isEmpty())
            ftp->login(QUrl::fromPercentEncoding(url.userName().toLatin1()), url.password());
        else
            ftp->login();
        if (!url.path().isEmpty())
            ftp->cd(url.path());
        ftp1->connectToHost(url.host(), url.port(21));

        /*if (!url.userName().isEmpty())
            ftp1->login(QUrl::fromPercentEncoding(url.userName().toLatin1()), url.password());
        else
            ftp1->login();
        if (!url.path().isEmpty())
            ftp1->cd(url.path());*/
    }

    fileList->setEnabled(true);
    connectButton->setEnabled(false);
    connectButton->setText(tr("Disconnect"));
    statusLabel->setText(tr("Connecting to FTP server %1...").arg(ftpServerLineEdit->text()));
Почему-то мой обработчик ftpDone()
    connect(ftp1, SIGNAL(done(bool)), this, SLOT(ftpDone(bool)));
срабатывает, хотя конект на ftp1 я делаю только в обработчике на другую кнопку
Поясните пожалуйста
Записан
Amigo_sa
Гость
« Ответ #1 : Апрель 19, 2010, 19:06 »

    isDirectory.clear();
    QUrl url(ftpServerLineEdit->text());
    if (!url.isValid() || url.scheme().toLower() != QLatin1String("ftp"))
    {
        ftp->connectToHost(ftpServerLineEdit->text(), 21);
        ftp->login();

    }
    else
    {
        ftp->connectToHost(url.host(), url.port(21));

        if (!url.userName().isEmpty())
            ftp->login(QUrl::fromPercentEncoding(url.userName().toLatin1()), url.password());
        else
            ftp->login();
        if (!url.path().isEmpty())
            ftp->cd(url.path());
        ftp1->connectToHost(url.host(), url.port(21));

Почему-то мой обработчик ftpDone()
    connect(ftp1, SIGNAL(done(bool)), this, SLOT(ftpDone(bool)));
срабатывает, хотя конект на ftp1 я делаю только в обработчике на другую кнопку
Поясните пожалуйста
а разве тут нет коннекта на фтп1?
Плиз, не перегружайте код закомментаренными кусками, оч неудобно
Записан
B_u_R_n
Гость
« Ответ #2 : Апрель 20, 2010, 05:52 »

Млин, и правда, спасибо огромное
Записан
Страниц: [1]   Вверх
  Печать  
 
Перейти в:  


Страница сгенерирована за 0.121 секунд. Запросов: 20.