[Development] Qt 5 QSessionManager

Samuel Gaist samuel.gaist at edeltech.ch
Mon Jul 22 22:55:45 CEST 2013

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.
>> If I have understood correctly the rules for keeping binary
>> compatibility (from the kde techbase entry) it is forbidden to change
>> a function from non-virtual to virtual (please correct me if I'm
>> wrong), in that case would the Q_GLOBAL_STATIC QHash technique be the
>> way to go ?
> Given the above, I don't think you need to go for any of this.
> Ciao,
>  Alberto
> -- 
> http://blog.mardy.it <- geek in un lingua international!

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 ?

More information about the Development mailing list