[fpc-pascal] Problem with multiple inheritance

Marc Weustink marc at dommelstein.net
Thu Nov 2 23:43:49 CET 2006


Felipe Monteiro de Carvalho wrote:
> Hello,
> 
> I was trying to split the o-o wrappers around Qt procedural wrappers
> in 2 parts. One that depends on Lazarus and another that can be used
> with only Free Pascal.
> 
> So I have some classes like this:
> 
> TQtWidget = class(TObject)
> 
> TQtFrame = class(TQtWidget)
> 
> Both classes contain mixed code for accessing Qt functions and
> procedures specific for Lazarus, like Event loops, methods that
> receive lazarus classes, methods to receive event signals, etc.
> 
> So I would now have, after splitting:
> 
> For pure Qt:
> 
> TQtWidget = class(TObject)
> 
> TQtFrame = class(TQtWidget)
> 
> And for laz parts:
> 
> TLazQtWidget = class(TObject)
> 
> TLazQtFrame = class(TLazQtWidget, TQtFrame)
> 
> The problem is that on TLazQtFrame I would like to inherit all
> functions from a normal TQtFrame, but I would also like to inherit all
> functions from TLazQtWidget.
> 
> How can I work around this? I mean, how can I redesign my idea to make
> it work with FP?
> 
> Note that Qt requires that all methods to receive events, and signals
> be from objects (I cannot use a procedure to receive events).

Use the TQt class tree as a private for the TQtWS class tree. The Qt
tree doesn't have to match 1:1 to the WS tree.

(exactly this problem made me inplement the virtusl classes :)

Marc




More information about the fpc-pascal mailing list