Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Tips on design and better usage of QT

    General and Desktop
    2
    4
    813
    Loading More Posts
    • 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.
    • saeedhardan
      saeedhardan last edited by

      Hi,
      i have this function :
      @
      void Signatures::read_pcaps_path();
      @

      that is called by signal , meaning when some button is clicked it triggers a signal and this function is the handler of that signal.
      inside this function i want to call a function in other thread , this function is :
      @
      void upload_multiple_files_to_ftp(ACS_session acs_session,QStringList file_paths,QTextEdit*& console);
      @
      how i call it :
      @
      QFuture<void> future = QtConcurrent::run(upload_multiple_files_to_ftp,acs_session, file_paths,ui->console);
      @
      notice the "ui->console" which is a QTextEdit that i have to send it to the upload_multiple_files_to_ftp function because it is not in the Signatures:: class where there is the ui->console .

      This code works , but i get the output :
      [quote]
      QObject::connect: Cannot queue arguments of type 'QTextBlock'
      (Make sure 'QTextBlock' is registered using qRegisterMetaType().)
      QObject::connect: Cannot queue arguments of type 'QTextCursor'
      (Make sure 'QTextCursor' is registered using qRegisterMetaType().)
      [/quote]

      is this the best way to call a function in other thread and in that thread do some actions sequentially?
      what i mean is that in the upload_multiple_files_to_ftp function (which is run in other thread) i upload files one after the other each upload is a blocking function because i want to know if the uploading is done successfully before moving to the next one .

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        @QTextEdit*& console@

        *&: is it a typo ?

        The problem is not the sequence. You are trying to transmit over signal and slots an unknown type. Anyway you are also trying to update a GUI element directly from another thread which is not possible. That requires signal and slots.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • saeedhardan
          saeedhardan last edited by

          Hi,
          yeah its a typo xD , but the GUI element does get updated .
          as for the signal,slot , how do i do that ? since the upload_multiple_files_to_ftp is a static function not in any class .

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            Did you considered the use of "QFuture":http://doc.qt.io/qt-5/qfuture.html#details ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 0
            • First post
              Last post