I am currently having a problem in using a third party SDK. It involves some Qt, but since it's primarly C++ related I post it here.

The SDK consists of a range of classes, all derived from the same base class. There is a static callback function in this base class, which is used for error handling. Normally this callback is just set by the user once in the beginning, typically by allowing for some dialog to be displayed when errors occur.

I would like to use a QErrorMessage object inside my callback function, but there is a problem there. I have a QMainWindow based class, where I construct the QErrorMessage in the QMainWindow constructor. I noticed QErrorMessage can not be created on the stack, otherwise the dialog disappears immediately. So I have to do it this way.

Now, if I don't make the QMainWindow class the parent of QErrorMessage, I get weird behaviour. In the other scenario, I have a whole lot of problems. The QErrorMessage object is a member of my QMainWindow class and is not-static. Therefore, it can not be used in my static callback function. If I make the QErrorMessage static, it can not have the QMainWindow object as a parent. And trying to work around this just has me going round and round and ...

Basically, I'm just looking for a work-around to give static functions (a static error handling function inside my QMainWindow object) access to members of the class. I know it can not be done normally, therefor the work-around question