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. Tips on design and better usage of QT

Tips on design and better usage of QT

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.1k 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.
  • saeedhardanS Offline
    saeedhardanS Offline
    saeedhardan
    wrote on last edited by
    #1

    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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      0
      • saeedhardanS Offline
        saeedhardanS Offline
        saeedhardan
        wrote on last edited by
        #3

        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
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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
          0

          • Login

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