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. Please - explain the purpose of highlighted code
Forum Updated to NodeBB v4.3 + New Features

Please - explain the purpose of highlighted code

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 210 Views 2 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on 29 Mar 2022, 01:01 last edited by
    #1

    I am posting this to gain understanding of the purpose of highlighted code.
    This is taken from QT doc on how to pass parameters to QtConncurrent :run function.

    I do not need any more instruction - just answer to this question.

    Reference to document would be nice - QT doc does not say why it is necessary.
    I can "pass " int integer = xxx; however I do not know how to pass a pointer.
    For example "struct ptr ??? " .

    extern void aFunctionWithArguments(int arg1, double arg2, const QString &string);
    
    **int integer = ...;
    double floatingPoint = ...;
    QString string = ...;**
    
    QFuture<void> future = QtConcurrent::run(aFunctionWithArguments, integer, floatingPoint, string);
    
    J 1 Reply Last reply 29 Mar 2022, 01:54
    0
    • A Anonymous_Banned275
      29 Mar 2022, 01:01

      I am posting this to gain understanding of the purpose of highlighted code.
      This is taken from QT doc on how to pass parameters to QtConncurrent :run function.

      I do not need any more instruction - just answer to this question.

      Reference to document would be nice - QT doc does not say why it is necessary.
      I can "pass " int integer = xxx; however I do not know how to pass a pointer.
      For example "struct ptr ??? " .

      extern void aFunctionWithArguments(int arg1, double arg2, const QString &string);
      
      **int integer = ...;
      double floatingPoint = ...;
      QString string = ...;**
      
      QFuture<void> future = QtConcurrent::run(aFunctionWithArguments, integer, floatingPoint, string);
      
      J Offline
      J Offline
      JKSH
      Moderators
      wrote on 29 Mar 2022, 01:54 last edited by
      #2

      @AnneRanch said in Please - explain the purpose of highlighted code:

      I am posting this to gain understanding of the purpose of highlighted code.

      When you say "highlighted code", do you mean the part that you wrapped in ** ... ** symbols?

      Its purpose is to store values inside variables. That's all.

      QT doc does not say why it is necessary.

      It is not necessary, it is just very common.

      This code:

      int integer = 12;
      double floatingPoint = 3.4;
      QString string = "Fifty-six";
      QFuture<void> future = QtConcurrent::run(aFunctionWithArguments, integer, floatingPoint, string);
      

      ...does exactly the same thing as this code:

      QFuture<void> future = QtConcurrent::run(aFunctionWithArguments, 12, 3.4, "Fifty-six");
      

      I can "pass " int integer = xxx; however I do not know how to pass a pointer.

      You must first write a function that accepts a pointer as a parameter.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      A 1 Reply Last reply 29 Mar 2022, 03:58
      2
      • J JKSH
        29 Mar 2022, 01:54

        @AnneRanch said in Please - explain the purpose of highlighted code:

        I am posting this to gain understanding of the purpose of highlighted code.

        When you say "highlighted code", do you mean the part that you wrapped in ** ... ** symbols?

        Its purpose is to store values inside variables. That's all.

        QT doc does not say why it is necessary.

        It is not necessary, it is just very common.

        This code:

        int integer = 12;
        double floatingPoint = 3.4;
        QString string = "Fifty-six";
        QFuture<void> future = QtConcurrent::run(aFunctionWithArguments, integer, floatingPoint, string);
        

        ...does exactly the same thing as this code:

        QFuture<void> future = QtConcurrent::run(aFunctionWithArguments, 12, 3.4, "Fifty-six");
        

        I can "pass " int integer = xxx; however I do not know how to pass a pointer.

        You must first write a function that accepts a pointer as a parameter.

        A Offline
        A Offline
        Anonymous_Banned275
        wrote on 29 Mar 2022, 03:58 last edited by
        #3

        @JKSH I was under wrong impression that the function parameters names ( TYPE) passed to " run" should have same names as used in the function declaration. SOLVED

        1 Reply Last reply
        0

        1/3

        29 Mar 2022, 01:01

        • Login

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