[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    KDialogBase problem with KGuiItem
From:       Martijn Klingens <mklingens () ism ! nl>
Date:       2001-11-29 16:46:07
[Download RAW message or body]

Short question: is it possible to add a copy constructor and/or operator= to 
QObject derived classes? I need to be able to copy those objects, or I will 
have a much bigger problem. And the copy ctor in QObject is private, which 
makes me seriously doubt whether this will work.

Long question (in case the short question resolves to 'no'):
I am having a problem with KDialogBase. I want to change KGuiItem into a 
QObject so I can emit signals from a gui item. But that has some 
complications for KDialogBase.

Currently KDialogBase takes elements of type 'KGuiItem&' in its constructors. 
Since KGuiItem has a constructor that takes a 'const QString &', there will 
be an implicit conversion and code that is written for KDE 2.x's KDialogBase 
will still work. (In 2.x those same functions took a 'const QString&'.)

If I change KGuiItem from a simple class to a QObject I don't think I can 
make copies of QObjects, so I have to drop the copy ctor and the assignment 
operator. If I _can_ make copies, please tell me, because that would 
instantly solve my problem.

If I drop the copy ctor and operator= the problem moves to KDialogBase, which 
takes a 'KGuiItem&' and hence tries to make copies of the arguments. So I 
changed the type into 'KGuiItem *' instead. But that in turn breaks the 
implicit conversion from QString.

And now I wonder what to do. I can see only one solutions of which I'm pretty 
sure it will work: add a whole slew of additional constructors to KdialogBase 
that take Qstrings, next to those that take KGuiItems. But that is ugly code 
at its best IMO.

Like I said, adding a copy ctor and operator= to KGuiItem would by far be the 
best approach, but will it work? And otherwise, any ideas on how to solve 
this?

Martijn
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic