[Development] Qt 5 QSessionManager

David Faure david.faure at kdab.com
Mon Jul 22 23:07:23 CEST 2013


On Monday 22 July 2013 22:55:45 Samuel Gaist wrote:
> On 22 juil. 2013, at 10:25, Alberto Mardegan wrote:
> > On 07/21/2013 01:21 AM, Samuel Gaist wrote:
> > [...]
> > 
> >> Now there's the wall: all functions from QSessionManager are
> >> non virtual (even the destructor) and it has no d pointer, so
> >> subclassing it will prove to be complicated.
> > 
> > Not really: the destructor is virtual, because the class inherits from
> > QObject, whose destructor is virtual.
> > Also, there is a d pointer, the one from QObject: QObject provides a
> > constructor which takes a QObjectPrivate class. You can subclass
> > QObjectPrivate, add your members, and then pass your QObjectPrivate
> > subclass to the QObject constructor when you initialize it.
> > 
> 
> But since both constructor and destructor are private, AFAIK, I can't just
> subclass it. Only a friend object or a class function can create a
> QSessionManager.
> 
> Currently, I don't see any way to specialize QSessionManager in a platform
> independent no binary breaking way (thinking QPA).
> 
> The only alternative that comes to my mind at this time would be to use
> platform #ifdefs in qsessionmanager.cpp and modify QSessionManagerPrivate
> to contain what would be needed. But it doesn't feel right to me.
> 
> Any idea or suggestion ?

I think you should create a new QPA base class with virtuals and just let the 
public QSessionManager forward calls to that class.

And then QPA plugins can reimplement the virtuals from the internal QPA base 
class.

-- 
David Faure | david.faure at kdab.com | Managing Director KDAB France
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-independent software solutions




More information about the Development mailing list