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. Signal/Slot between a QT application and a non qt c++ code
Qt 6.11 is out! See what's new in the release blog

Signal/Slot between a QT application and a non qt c++ code

Scheduled Pinned Locked Moved Solved General and Desktop
18 Posts 4 Posters 3.0k 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.
  • ademmlerA ademmler

    @Christian-Ehrlicher

    Hi Christian,

    you mean something like this:

    void myHelper() {
    int err = mySDKroutine(parameters );
    }

    But still I do not see how the sdk can tell me how far the progress went ...

    Christian EhrlicherC Online
    Christian EhrlicherC Online
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote on last edited by
    #4

    @ademmler But where's the Qt problem here? If your SDK returns a progress value e.g. due to a callback then set it to a function in your helper class and emit a signal then.

    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
    Visit the Qt Academy at https://academy.qt.io/catalog

    ademmlerA 1 Reply Last reply
    0
    • Christian EhrlicherC Christian Ehrlicher

      @ademmler But where's the Qt problem here? If your SDK returns a progress value e.g. due to a callback then set it to a function in your helper class and emit a signal then.

      ademmlerA Offline
      ademmlerA Offline
      ademmler
      wrote on last edited by
      #5

      @Christian-Ehrlicher said in Signal/Slot between a QT application and a non qt c++ code:

      If your SDK returns a progress value e.g. due to a callback then set it to a function in your helper class and emit a signal then.

      I have not said there is a qt problem. I was asking for the best practise.
      Single line answers are ambiguous to understand.
      As far as I know "callbacks" are not available in qt.
      May somebody posts a link to a working sample or some code lines here?

      1 Reply Last reply
      0
      • Christian EhrlicherC Online
        Christian EhrlicherC Online
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #6

        @ademmler said in Signal/Slot between a QT application and a non qt c++ code:

        As far as I know "callbacks" are not available in qt.

        I said when your SDK provides a callback to report the progress you can set it to a function of your helper class.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        ademmlerA 1 Reply Last reply
        0
        • Christian EhrlicherC Christian Ehrlicher

          @ademmler said in Signal/Slot between a QT application and a non qt c++ code:

          As far as I know "callbacks" are not available in qt.

          I said when your SDK provides a callback to report the progress you can set it to a function of your helper class.

          ademmlerA Offline
          ademmlerA Offline
          ademmler
          wrote on last edited by
          #7

          @Christian-Ehrlicher It does not give a callback.

          Christian EhrlicherC 1 Reply Last reply
          0
          • ademmlerA ademmler

            @Christian-Ehrlicher It does not give a callback.

            Christian EhrlicherC Online
            Christian EhrlicherC Online
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #8

            @ademmler So when your SDK does not provide a progress indicator you can't display any progress, or?

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            ademmlerA 1 Reply Last reply
            2
            • Christian EhrlicherC Christian Ehrlicher

              @ademmler So when your SDK does not provide a progress indicator you can't display any progress, or?

              ademmlerA Offline
              ademmlerA Offline
              ademmler
              wrote on last edited by ademmler
              #9

              @Christian-Ehrlicher You are right - that's why I asked the SDK developer to do so. But he asked me how I will use it in qt .... I am just in the middle of question ;-) that's why I asked for some example :-)
              thx for your help.

              Christian EhrlicherC Pablo J. RoginaP 2 Replies Last reply
              0
              • ademmlerA ademmler

                @Christian-Ehrlicher You are right - that's why I asked the SDK developer to do so. But he asked me how I will use it in qt .... I am just in the middle of question ;-) that's why I asked for some example :-)
                thx for your help.

                Christian EhrlicherC Online
                Christian EhrlicherC Online
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #10

                @ademmler He should provide a function to report the progress as callback function. So you can pass a function pointer to your helper class function.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                ademmlerA 1 Reply Last reply
                0
                • ademmlerA ademmler

                  @Christian-Ehrlicher You are right - that's why I asked the SDK developer to do so. But he asked me how I will use it in qt .... I am just in the middle of question ;-) that's why I asked for some example :-)
                  thx for your help.

                  Pablo J. RoginaP Offline
                  Pablo J. RoginaP Offline
                  Pablo J. Rogina
                  wrote on last edited by
                  #11

                  @ademmler said in Signal/Slot between a QT application and a non qt c++ code:

                  But he asked me how I will use it in qt

                  I'd say it doesn't matter from the point of view of the SDK (and the SDK developer). Just make the SDK provide a callback function, as it will be used by any C++ program or one just happening to use Qt framework.

                  Upvote the answer(s) that helped you solve the issue
                  Use "Topic Tools" button to mark your post as Solved
                  Add screenshots via postimage.org
                  Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                  ademmlerA 1 Reply Last reply
                  2
                  • Pablo J. RoginaP Pablo J. Rogina

                    @ademmler said in Signal/Slot between a QT application and a non qt c++ code:

                    But he asked me how I will use it in qt

                    I'd say it doesn't matter from the point of view of the SDK (and the SDK developer). Just make the SDK provide a callback function, as it will be used by any C++ program or one just happening to use Qt framework.

                    ademmlerA Offline
                    ademmlerA Offline
                    ademmler
                    wrote on last edited by
                    #12

                    @Pablo-J-Rogina and @Christian-Ehrlicher

                    thx for your ideas.

                    1 Reply Last reply
                    0
                    • Christian EhrlicherC Christian Ehrlicher

                      @ademmler He should provide a function to report the progress as callback function. So you can pass a function pointer to your helper class function.

                      ademmlerA Offline
                      ademmlerA Offline
                      ademmler
                      wrote on last edited by ademmler
                      #13

                      @Christian-Ehrlicher and @Pablo-J-Rogina

                      Hi Pablo and christian, I do not get this connection between sdk callback and qt application to work.
                      Is there a real live example somewhere - from what I can learn?
                      Would you be so kind to point me to this?

                      Pablo J. RoginaP 1 Reply Last reply
                      0
                      • ademmlerA ademmler

                        @Christian-Ehrlicher and @Pablo-J-Rogina

                        Hi Pablo and christian, I do not get this connection between sdk callback and qt application to work.
                        Is there a real live example somewhere - from what I can learn?
                        Would you be so kind to point me to this?

                        Pablo J. RoginaP Offline
                        Pablo J. RoginaP Offline
                        Pablo J. Rogina
                        wrote on last edited by
                        #14

                        @ademmler said in Signal/Slot between a QT application and a non qt c++ code:

                        sdk callback

                        at a very least, you should have already provided a link to such SDK...

                        Upvote the answer(s) that helped you solve the issue
                        Use "Topic Tools" button to mark your post as Solved
                        Add screenshots via postimage.org
                        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                        ademmlerA 1 Reply Last reply
                        0
                        • Pablo J. RoginaP Pablo J. Rogina

                          @ademmler said in Signal/Slot between a QT application and a non qt c++ code:

                          sdk callback

                          at a very least, you should have already provided a link to such SDK...

                          ademmlerA Offline
                          ademmlerA Offline
                          ademmler
                          wrote on last edited by
                          #15

                          @Pablo-J-Rogina yes your are right - but it am not allowed to. It's private.

                          I get this error "no known conversion from 'void (SpectraProof::)(int)' to 'FuncPtrInt' (aka 'void ()(int)') for 6th argument"

                          What I have in the header file fo the SDK:
                          typedef void (*FuncPtrInt)(int);

                          In my main qt app (stripped code):
                          void myFunctionCallingTheSDK
                          {
                          err = chamo_nChanneltoRGB(nChannel_TIFF.toStdString(), RGB_TIFF.toStdString(), IP, jobSpotDefinitions.toStdString(), cmmPath.toStdString(), &updateProgress);
                          }

                          void SpectraProof::updateProgress(int percent)
                          {
                          qDebug() << "Progress: " + QString::number(percent);
                          ui->progressBar->setValue(percent);
                          }

                          JonBJ 1 Reply Last reply
                          0
                          • ademmlerA ademmler

                            @Pablo-J-Rogina yes your are right - but it am not allowed to. It's private.

                            I get this error "no known conversion from 'void (SpectraProof::)(int)' to 'FuncPtrInt' (aka 'void ()(int)') for 6th argument"

                            What I have in the header file fo the SDK:
                            typedef void (*FuncPtrInt)(int);

                            In my main qt app (stripped code):
                            void myFunctionCallingTheSDK
                            {
                            err = chamo_nChanneltoRGB(nChannel_TIFF.toStdString(), RGB_TIFF.toStdString(), IP, jobSpotDefinitions.toStdString(), cmmPath.toStdString(), &updateProgress);
                            }

                            void SpectraProof::updateProgress(int percent)
                            {
                            qDebug() << "Progress: " + QString::number(percent);
                            ui->progressBar->setValue(percent);
                            }

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

                            @ademmler said in Signal/Slot between a QT application and a non qt c++ code:

                            typedef void (*FuncPtrInt)(int);

                            Before you go any farther: that looks like it's expecting a simple C-style function? You will need a C++ expert here to confirm: I don't think you can call a C++ class member method (your SpectraProof::updateProgress(int)) like this, there's no this?

                            1 Reply Last reply
                            0
                            • Christian EhrlicherC Online
                              Christian EhrlicherC Online
                              Christian Ehrlicher
                              Lifetime Qt Champion
                              wrote on last edited by
                              #17

                              @JonB said in Signal/Slot between a QT application and a non qt c++ code:

                              I don't think you can call a C++ class member method

                              correct. That's why some callback functions take a function pointer + a custom 'void* userData' which takes e.g. this as userData. If this is not available you need a global ptr.

                              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                              Visit the Qt Academy at https://academy.qt.io/catalog

                              ademmlerA 1 Reply Last reply
                              0
                              • Christian EhrlicherC Christian Ehrlicher

                                @JonB said in Signal/Slot between a QT application and a non qt c++ code:

                                I don't think you can call a C++ class member method

                                correct. That's why some callback functions take a function pointer + a custom 'void* userData' which takes e.g. this as userData. If this is not available you need a global ptr.

                                ademmlerA Offline
                                ademmlerA Offline
                                ademmler
                                wrote on last edited by
                                #18

                                @Christian-Ehrlicher @JonB

                                Ok gentlemen - it is really hard for me to follow your advices because I got lost ...
                                Would it be possible to give me some lines of code to illustrate your words?

                                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