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. QtConcurrent::run errors with Qt6
Qt 6.11 is out! See what's new in the release blog

QtConcurrent::run errors with Qt6

Scheduled Pinned Locked Moved Unsolved General and Desktop
15 Posts 5 Posters 3.1k 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.
  • M Offline
    M Offline
    mpvx
    wrote on last edited by
    #5

    _EncodeVideo.cpp

    bool cEncodeVideo::DoEncode() {
    ...
    if ((!PreviousFrame)||(PreviousFrame->RenderedImage.isNull()))          ThreadAssembly.setFuture(QtConcurrent::run(&cEncodeVideo::Assembly,this,Frame,PreviousFrame,&RenderMusic,&ToEncodeMusic,Continue));
    ...
    }
    
    void cEncodeVideo::Assembly(cDiaporamaObjectInfo *Frame,cDiaporamaObjectInfo *PreviousFrame,cSoundBlockList *RenderMusic,cSoundBlockList *ToEncodeMusic,bool &Continue) {
    ...
    }
    
    1 Reply Last reply
    0
    • A Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #6

      Is cEncodeVideo::Assembly a member function?
      Not sure QtConcurrent::run is able to bind together &cEncodeVideo::Assembly and the 'this' argument.
      Try wrapping that part of the call into a lambda, or use std::mem_fn
      Or some of the other arguments has a type mismatch.

      JonBJ 1 Reply Last reply
      0
      • A Asperamanca

        Is cEncodeVideo::Assembly a member function?
        Not sure QtConcurrent::run is able to bind together &cEncodeVideo::Assembly and the 'this' argument.
        Try wrapping that part of the call into a lambda, or use std::mem_fn
        Or some of the other arguments has a type mismatch.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #7

        @Asperamanca said in QtConcurrent::run errors with Qt6:

        Is cEncodeVideo::Assembly a member function?
        Not sure QtConcurrent::run is able to bind together &cEncodeVideo::Assembly and the 'this' argument.

        We do not know, because the OP has been asked to provide an example for us to check and they simply paste a couple of lines out of any context so nobody can tell....

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mpvx
          wrote on last edited by
          #8

          cEncodeVideo::Assembly is a class::function

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mpvx
            wrote on last edited by
            #9

            In other files with QtConcurrent::run ffDiaporama 2.1 works well only not in _EncodeVideo.cpp.

            gons@debian:~/Dokumente/_prog/_ffdiaporama/_qt6/_work_20250102/_work2/ffdiaporama-2.1$ find . -name '*' -type f -exec grep -q QtConcurrent::run {} \; -print
            ./src/ffDiaporama/wgt_QVideoPlayer/wgt_QVideoPlayer.cpp
            ./src/ffDiaporama/engine/_Diaporama.cpp
            ./src/ffDiaporama/engine/_EncodeVideo.cpp
            ./src/ffDiaporama/DlgExportProject/DlgExportProject.cpp
            ./src/ffDiaporama/DlgRenderVideo/DlgRenderVideo.cpp
            ./src/ffDiaporama/wgt_QMultimediaBrowser/QCustomFolderTable.cpp
            
            1 Reply Last reply
            0
            • A Offline
              A Offline
              Asperamanca
              wrote on last edited by
              #10

              It's a bit frustrating. You mention code we can't know, instead of providing sufficient source code to identify and name the problem (even when asked to do so).
              I have given you leads on how to identify and fix the problem yourself, but you did not answer them.

              1 Reply Last reply
              1
              • M Offline
                M Offline
                mpvx
                wrote on last edited by
                #11

                The code is here (ffDiaporama 2.1)
                https://sourceforge.net/projects/ffdiaporama/files/ffdiaporama_bin_2.1.2014.0209.tar.gz
                The translation in Qt6 is here
                https://sourceforge.net/projects/ffdiaporama/files/qt6/ffdiaporama_2.1-1.diff.gz

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mpvx
                  wrote on last edited by
                  #12

                  If I use

                  ThreadAssembly.setFuture(QtConcurrent::run([=]{Assembly(Frame,PreviousFrame,&RenderMusic,&ToEncodeMusic,Continue)}));
                  

                  as solution corresponding to link text
                  I get

                  engine/_EncodeVideo.cpp: In lambda function:
                  engine/_EncodeVideo.cpp:930:89: error: invalid conversion from ‘const cSoundBlockList*’ to ‘cSoundBlockList*’ [-fpermissive]
                    930 |             ThreadAssembly.setFuture(QtConcurrent::run([=]{Assembly(Frame,PreviousFrame,&RenderMusic,&ToEncodeMusic,Continue)}));
                        |                                                                                         ^~~~~~~~~~~~
                        |                                                                                         |
                        |                                                                                         const cSoundBlockList*
                  engine/_EncodeVideo.h:126:111: note:   initializing argument 3 of ‘void cEncodeVideo::Assembly(cDiaporamaObjectInfo*, cDiaporamaObjectInfo*, cSoundBlockList*, cSoundBlockList*, bool&)’
                    126 |     void            Assembly(cDiaporamaObjectInfo *Frame,cDiaporamaObjectInfo *PreviousFrame,cSoundBlockList *RenderMusic,cSoundBlockList *ToEncodeMusic,bool &Continue);
                        |                                                                                              ~~~~~~~~~~~~~~~~~^~~~~~~~~~~
                  engine/_EncodeVideo.cpp:930:102: error: invalid conversion from ‘const cSoundBlockList*’ to ‘cSoundBlockList*’ [-fpermissive]
                    930 |             ThreadAssembly.setFuture(QtConcurrent::run([=]{Assembly(Frame,PreviousFrame,&RenderMusic,&ToEncodeMusic,Continue)}));
                        |                                                                                                      ^~~~~~~~~~~~~~
                        |                                                                                                      |
                        |                                                                                                      const cSoundBlockList*
                  engine/_EncodeVideo.h:126:140: note:   initializing argument 4 of ‘void cEncodeVideo::Assembly(cDiaporamaObjectInfo*, cDiaporamaObjectInfo*, cSoundBlockList*, cSoundBlockList*, bool&)’
                    126 |     void            Assembly(cDiaporamaObjectInfo *Frame,cDiaporamaObjectInfo *PreviousFrame,cSoundBlockList *RenderMusic,cSoundBlockList *ToEncodeMusic,bool &Continue);
                        |                                                                                                                           ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
                  engine/_EncodeVideo.cpp:930:117: error: binding reference of type ‘bool&’ to ‘const bool’ discards qualifiers
                    930 |             ThreadAssembly.setFuture(QtConcurrent::run([=]{Assembly(Frame,PreviousFrame,&RenderMusic,&ToEncodeMusic,Continue)}));
                        |                                                                                                                     ^~~~~~~~
                  engine/_EncodeVideo.h:126:160: note:   initializing argument 5 of ‘void cEncodeVideo::Assembly(cDiaporamaObjectInfo*, cDiaporamaObjectInfo*, cSoundBlockList*, cSoundBlockList*, bool&)’
                    126 |     void            Assembly(cDiaporamaObjectInfo *Frame,cDiaporamaObjectInfo *PreviousFrame,cSoundBlockList *RenderMusic,cSoundBlockList *ToEncodeMusic,bool &Continue);
                        |                                                                                                                                                          ~~~~~~^~~~~~~~
                  engine/_EncodeVideo.cpp: In member function ‘bool cEncodeVideo::DoEncode()’:
                  engine/_EncodeVideo.cpp:930:56: error: use of deleted function ‘cSoundBlockList::cSoundBlockList(const cSoundBlockList&)’
                    930 |             ThreadAssembly.setFuture(QtConcurrent::run([=]{Assembly(Frame,PreviousFrame,&RenderMusic,&ToEncodeMusic,Continue)}));
                        |                                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  
                  A 1 Reply Last reply
                  0
                  • M mpvx

                    If I use

                    ThreadAssembly.setFuture(QtConcurrent::run([=]{Assembly(Frame,PreviousFrame,&RenderMusic,&ToEncodeMusic,Continue)}));
                    

                    as solution corresponding to link text
                    I get

                    engine/_EncodeVideo.cpp: In lambda function:
                    engine/_EncodeVideo.cpp:930:89: error: invalid conversion from ‘const cSoundBlockList*’ to ‘cSoundBlockList*’ [-fpermissive]
                      930 |             ThreadAssembly.setFuture(QtConcurrent::run([=]{Assembly(Frame,PreviousFrame,&RenderMusic,&ToEncodeMusic,Continue)}));
                          |                                                                                         ^~~~~~~~~~~~
                          |                                                                                         |
                          |                                                                                         const cSoundBlockList*
                    engine/_EncodeVideo.h:126:111: note:   initializing argument 3 of ‘void cEncodeVideo::Assembly(cDiaporamaObjectInfo*, cDiaporamaObjectInfo*, cSoundBlockList*, cSoundBlockList*, bool&)’
                      126 |     void            Assembly(cDiaporamaObjectInfo *Frame,cDiaporamaObjectInfo *PreviousFrame,cSoundBlockList *RenderMusic,cSoundBlockList *ToEncodeMusic,bool &Continue);
                          |                                                                                              ~~~~~~~~~~~~~~~~~^~~~~~~~~~~
                    engine/_EncodeVideo.cpp:930:102: error: invalid conversion from ‘const cSoundBlockList*’ to ‘cSoundBlockList*’ [-fpermissive]
                      930 |             ThreadAssembly.setFuture(QtConcurrent::run([=]{Assembly(Frame,PreviousFrame,&RenderMusic,&ToEncodeMusic,Continue)}));
                          |                                                                                                      ^~~~~~~~~~~~~~
                          |                                                                                                      |
                          |                                                                                                      const cSoundBlockList*
                    engine/_EncodeVideo.h:126:140: note:   initializing argument 4 of ‘void cEncodeVideo::Assembly(cDiaporamaObjectInfo*, cDiaporamaObjectInfo*, cSoundBlockList*, cSoundBlockList*, bool&)’
                      126 |     void            Assembly(cDiaporamaObjectInfo *Frame,cDiaporamaObjectInfo *PreviousFrame,cSoundBlockList *RenderMusic,cSoundBlockList *ToEncodeMusic,bool &Continue);
                          |                                                                                                                           ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
                    engine/_EncodeVideo.cpp:930:117: error: binding reference of type ‘bool&’ to ‘const bool’ discards qualifiers
                      930 |             ThreadAssembly.setFuture(QtConcurrent::run([=]{Assembly(Frame,PreviousFrame,&RenderMusic,&ToEncodeMusic,Continue)}));
                          |                                                                                                                     ^~~~~~~~
                    engine/_EncodeVideo.h:126:160: note:   initializing argument 5 of ‘void cEncodeVideo::Assembly(cDiaporamaObjectInfo*, cDiaporamaObjectInfo*, cSoundBlockList*, cSoundBlockList*, bool&)’
                      126 |     void            Assembly(cDiaporamaObjectInfo *Frame,cDiaporamaObjectInfo *PreviousFrame,cSoundBlockList *RenderMusic,cSoundBlockList *ToEncodeMusic,bool &Continue);
                          |                                                                                                                                                          ~~~~~~^~~~~~~~
                    engine/_EncodeVideo.cpp: In member function ‘bool cEncodeVideo::DoEncode()’:
                    engine/_EncodeVideo.cpp:930:56: error: use of deleted function ‘cSoundBlockList::cSoundBlockList(const cSoundBlockList&)’
                      930 |             ThreadAssembly.setFuture(QtConcurrent::run([=]{Assembly(Frame,PreviousFrame,&RenderMusic,&ToEncodeMusic,Continue)}));
                          |                                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                    
                    A Offline
                    A Offline
                    Asperamanca
                    wrote on last edited by
                    #13

                    @mpvx
                    Here is what I would recommend you to do:

                    • Create a static dummy function without parameters
                    • Test whether calling QtConcurrent::run with that dummy function works
                    • Create a member dummy function without parameters
                    • Test whether you can call them
                    • One by one, start adding your parameters to the dummy function. It does not need to do anything with them, just accept them
                    • Find out at which point the code no longer compiles

                    If, at that point, you cannot figure out what exactly the problem is, post

                    • your dummy function
                    • the code that calls the dummy function
                    1 Reply Last reply
                    2
                    • M Offline
                      M Offline
                      mpvx
                      wrote on last edited by mpvx
                      #14

                      I use now only the command

                      Assembly(Frame,PreviousFrame,&RenderMusic,&ToEncodeMusic,Continue);
                      

                      and it works.

                      1 Reply Last reply
                      0
                      • J Offline
                        J Offline
                        jawadulhassan
                        wrote on last edited by
                        #15

                        It looks like Qt6’s QtConcurrent::run no longer supports passing a raw pointer to a member function the way Qt5 did. You’ll need to use a lambda or std::bind to wrap the member function call. For example:
                        ThreadAssembly.setFuture(QtConcurrent::run(= {
                        this->Assembly(Frame, PreviousFrame, &RenderMusic, &ToEncodeMusic, Continue);
                        }));
                        This way, the function becomes a callable object compatible with Qt6’s QtConcurrent::run. It should fix the operator() / ArgResolver errors you’re seeing.

                        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