Signal/Slot between a QT application and a non qt c++ code
-
@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.
-
Create a helper object and call the SDK api function in a slot there.
-
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 ...
-
@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.
-
@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? -
@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.
-
@Christian-Ehrlicher It does not give a callback.
-
@ademmler So when your SDK does not provide a progress indicator you can't display any progress, or?
-
@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. -
@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.
-
@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.
-
@Pablo-J-Rogina and @Christian-Ehrlicher
thx for your ideas.
-
@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? -
@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...
-
@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);
} -
@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 nothis
? -
@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. -
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?