[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: KDialogBase problem with KGuiItem
From: David Faure <david () mandrakesoft ! com>
Date: 2001-11-29 17:09:11
[Download RAW message or body]
On Thursday 29 November 2001 17:46, Martijn Klingens wrote:
> 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.
You can't do that, QObjects can't be copied.
> 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.
I think QObject is a bit too heavyweight for KGuiItem. We already have KAction
for the "object that can be activated" concept. KGuiItem was supposed to be
only a repository of some settings, nothing more.
> 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.
You can use a reference just like a pointer, using &arg. But in both cases
this relies on the caller not destroying the object, if you don't copy it.
> 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?
I think the first step is to re-evaluate the idea of emitting signals from KGuiItem.
Then, if you really want to do that, you can use &arg to get the address of the
argument, with no need for copying it.
--
David FAURE, david@mandrakesoft.com, faure@kde.org
http://perso.mandrakesoft.com/~david/ , http://www.konqueror.org/
KDE 3.0: Konquering the Desktops
>> 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