Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to Login to my FTP Account
Forum Updated to NodeBB v4.3 + New Features

How to Login to my FTP Account

Scheduled Pinned Locked Moved Solved General and Desktop
26 Posts 3 Posters 8.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rezaMSLM
    wrote on last edited by
    #21

    when I click on login button and connectToHost() Command is executed how I notice that it's connected?
    I know that some signals are emitted but i dont know how to use them

    jsulmJ 1 Reply Last reply
    0
    • R rezaMSLM

      when I click on login button and connectToHost() Command is executed how I notice that it's connected?
      I know that some signals are emitted but i dont know how to use them

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #22

      @rezaMSLM

      MainWindow::MainWindow()
      {
          connect(&ftp, SIGNAL(stateChanged(int)), this, SLOT(checkState(int)));
      }
      
      void MainWindow::checkState(int state)
      {
          switch(state) {
          case QFtp::Connected:
              break;
          ...
          }
      }
      
      // From QFtp header file:
      enum State {
              Unconnected,
              HostLookup,
              Connecting,
              Connected,
              LoggedIn,
              Closing
      };
      

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      R 1 Reply Last reply
      2
      • jsulmJ jsulm

        @rezaMSLM

        MainWindow::MainWindow()
        {
            connect(&ftp, SIGNAL(stateChanged(int)), this, SLOT(checkState(int)));
        }
        
        void MainWindow::checkState(int state)
        {
            switch(state) {
            case QFtp::Connected:
                break;
            ...
            }
        }
        
        // From QFtp header file:
        enum State {
                Unconnected,
                HostLookup,
                Connecting,
                Connected,
                LoggedIn,
                Closing
        };
        
        R Offline
        R Offline
        rezaMSLM
        wrote on last edited by
        #23

        @jsulm Thanks alot

        1 Reply Last reply
        0
        • R Offline
          R Offline
          rezaMSLM
          wrote on last edited by
          #24

          my program has a BUG:
          when I'm already Connected to server and I Click on Connect button again none of the buttons will work.
          neither login nor disconnect buttons

          my mainwindow.cpp:

          #include "mainwindow.h"
          #include "ui_mainwindow.h"
          #include <QtNetwork/QFtp>
          
          
          MainWindow::MainWindow(QWidget *parent) :
              QMainWindow(parent),
              ui(new Ui::MainWindow)
          
          {
              ui->setupUi(this);
              ftp = new QFtp(parent);
              connect(ftp, SIGNAL(stateChanged(int)), this, SLOT(checkState(int)));
          }
          
          MainWindow::~MainWindow()
          {
              delete ui;
              delete ftp;
          }
          
          void MainWindow::checkState(int state)
          {
              switch(state) {
              case QFtp::Connected:
                  ui->Connect_Status_Label->setText("Connected");
                  break;
              case QFtp::Unconnected:
                  ui->Connect_Status_Label->setText("UnConnected");
                  ui->Login_Status_Label->setText("Logged Out");
                  break;
              case QFtp:: LoggedIn:
                  ui->Login_Status_Label->setText("Logged in");
                  break;
              }
          }
          
          void MainWindow::on_pushButton_Connect_clicked()
          {
              QString Host = ui->lineEdit_Host->text();
              ftp->connectToHost(Host);
          }
          
          void MainWindow::on_pushButton_Login_clicked()
          {
              QString UserName = ui->lineEdit_User->text();
              QString PassWord = ui->lineEdit_Pass->text();
              ftp->login(UserName,PassWord);
          }
          
          void MainWindow::on_pushButton_DisConnect_clicked()
          {
              ftp->close();
          }
          
          

          what is the reason?

          jsulmJ 1 Reply Last reply
          0
          • R rezaMSLM

            my program has a BUG:
            when I'm already Connected to server and I Click on Connect button again none of the buttons will work.
            neither login nor disconnect buttons

            my mainwindow.cpp:

            #include "mainwindow.h"
            #include "ui_mainwindow.h"
            #include <QtNetwork/QFtp>
            
            
            MainWindow::MainWindow(QWidget *parent) :
                QMainWindow(parent),
                ui(new Ui::MainWindow)
            
            {
                ui->setupUi(this);
                ftp = new QFtp(parent);
                connect(ftp, SIGNAL(stateChanged(int)), this, SLOT(checkState(int)));
            }
            
            MainWindow::~MainWindow()
            {
                delete ui;
                delete ftp;
            }
            
            void MainWindow::checkState(int state)
            {
                switch(state) {
                case QFtp::Connected:
                    ui->Connect_Status_Label->setText("Connected");
                    break;
                case QFtp::Unconnected:
                    ui->Connect_Status_Label->setText("UnConnected");
                    ui->Login_Status_Label->setText("Logged Out");
                    break;
                case QFtp:: LoggedIn:
                    ui->Login_Status_Label->setText("Logged in");
                    break;
                }
            }
            
            void MainWindow::on_pushButton_Connect_clicked()
            {
                QString Host = ui->lineEdit_Host->text();
                ftp->connectToHost(Host);
            }
            
            void MainWindow::on_pushButton_Login_clicked()
            {
                QString UserName = ui->lineEdit_User->text();
                QString PassWord = ui->lineEdit_Pass->text();
                ftp->login(UserName,PassWord);
            }
            
            void MainWindow::on_pushButton_DisConnect_clicked()
            {
                ftp->close();
            }
            
            

            what is the reason?

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by jsulm
            #25

            @rezaMSLM I don't understand: you're connected and then click connected again? Afterwards disconnect doesn't work? Does disconnect work if you don't click connect when already connected? You should disable the connect button if already connected and enable it when disconnected.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            R 1 Reply Last reply
            1
            • jsulmJ jsulm

              @rezaMSLM I don't understand: you're connected and then click connected again? Afterwards disconnect doesn't work? Does disconnect work if you don't click connect when already connected? You should disable the connect button if already connected and enable it when disconnected.

              R Offline
              R Offline
              rezaMSLM
              wrote on last edited by
              #26

              @jsulm said in How to Login to my FTP Account:

              you're connected and then click connected again? Afterwards disconnect doesn't work?

              yes

              @jsulm said in How to Login to my FTP Account:

              Does disconnect work if you don't click connect when already connected?

              yes

              @jsulm said in How to Login to my FTP Account:

              You should disable the connect button if already connected and enable it when disconnected.

              OK

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved