Incompatible pointer type when referencing the method.
-
@jsulm but how?
Sure, I can move that callback outside the class. That also means I'd need to somehow move the QDataStream outside... I am not sure if I know how to safely and correctly design that.
PdfWizard is of QMainWindow, so everything is in it. -
@artwaw said in Incompatible pointer type when referencing the method.:
Thank you but I don't know how to do that. I use lambdas with connect when needed, but my c++ skill is not enough.
this is untested:
FPDF_FILEWRITE writer; writer.version = 1; auto myFunction = [this](FPDF_FILEWRITE* pThis, const void* pData, unsigned long size)->int { Q_UNUSED(pThis) return writerStream.writeRawData(static_cast<const char*>(pData), size); } writer.WriteBlock = &myFunction; bool result = FPDF_SaveAsCopy(document, &writer,FPDF_INCREMENTAL);
-
@artwaw said in Incompatible pointer type when referencing the method.:
but how?
Well, you need to get access to the instance. One way is to make the class a singleton.
-
@jsulm said in Incompatible pointer type when referencing the method.:
make the class a singleton
I went here https://www.oreilly.com/library/view/c-cookbook/0596007612/ch08s10.html
This is doable, I think, but at this point I am coming to the conclusion that it would be better to redesign my approach by wrapping all interactions with PDFium into a separate class and only expose methods that do stuff I need.
There is so much I don't know how to do yet...
-
@artwaw oops, my bad, a lambda can only be converted to a function pointer if it does not capture
The closure type for a lambda-expression with no lambda-capture has a public non-virtual non-explicit const conversion function to pointer to function having the same parameter and return types as the closure type’s function call operator. The value returned by this conversion function shall be the address of a function that, when invoked, has the same effect as invoking the closure type’s function call operator.
-
@mpergand thank you but:
- I stated previously that I work with PDFium this time, as Poppler doesn't offer edits;
- I managed to work around without using static method: maybe not the nicest solution around but works.
At any rate I made a note of your comment in case I need to revisit this godawful file format known as PDF in the future.