[Kmymoney-devel] Re: kMyMoneyAccountSelector - Q_PROPERTY

Thomas Baumgart thb at net-bembel.de
Fri Oct 15 10:26:27 CEST 2010


Hi,

on Friday 15 October 2010 10:05:46 Cristian Oneţ wrote:

> On Fri, Oct 15, 2010 at 12:12 AM, Petr Bravenec <petr at bravenec.org> wrote:
> > I try to write some plugin for simple czech tax accounting. For that
> > plugin I need three different sets of accounts (income, expense and
> > monthly paid social and health insurance).
> >
> > I have created kcm module but i'm not able to save the setting of the
> > plugin. There is not written Q_PROPERTY for kMyMoneyAccountSelector class
> > (and i dont know how to create it now). The plugin needs to have the
> > settings of the widget saved.
> >
> > Without the Q_PROPERTY KMyMoney writes something like this:
> >
> > kmymoney(27457)/kdeui (KConfigDialogManager)
> > KConfigDialogManager::parseChildren: Don't know how to monitor widget '
> > kMyMoneyAccountSelector ' for changes!
> > kmymoney(27457)/kdeui (KConfigDialogManager)
> > KConfigDialogManager::property: kMyMoneyAccountSelector  widget not
> > handled!
> >
> > Please, can someone write the Q_PROPERTY for me? Sorry, i dont know how
> > difficult it is.
> 
> Hi Petr,
> 
> Writing a Q_PROPERTY is not that difficult once you know what you are
> looking for. So first of all let me ask you which property of the
> account selector would you like to save? Is it the selectedItems
> property? If so that would be something like adding the following
> line:
> Q_PROPERTY(QStringList selectedItems READ selectedItems WRITE selectItems)
> with the observation that you need to change the second parameter
> (state) of the selectItems function to have the default value true for
> this to work.
> After having done all this you must change the stateChanged to pass
> the current selection list so from stateChanged(void) change it to
> stateChanged(const QStringList &selection).
> With all this in place you are ready to use kMyMoneyAccountSelector as
> a KConfig property editor widget. For this you must register it in the
> KConfig system see
> http://api.kde.org/4.x-api/kdelibs-apidocs/kdeui/html/classKConfigDialogMan
> ager.html#_details
> 
> Your code would be something like:
> 
> KConfigDialogManager::changedMap()->insert("kMyMoneyAccountSelector ",
> SIGNAL(stateChanged(const QStringList &)));
> 
> kMyMoneyAccountSelector *myWidget = new kMyMoneyAccountSelector ;
> myWidget->setProperty("kcfg_property", QByteArray("selectedItems"));
> 
> You must use a StringList property in this case that will get saved
> into the configuration file.
> 
> Hope this helps, but if you encounter any further difficulties feel
> free to ask for assistance on this list.

Cool, I did not know that I could extend it in such a way. I guess I have to 
revisit my GPG settings dialog with that new piece of information.

Thanks for sharing.


-- 

Regards

Thomas Baumgart

GPG-FP: E55E D592 F45F 116B 8429   4F99 9C59 DB40 B75D D3BA
-------------------------------------------------------------
It is better to remain silent and be thought a fool,
than to speak, and remove all doubt.
-------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 225 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/kmymoney-devel/attachments/20101015/ee396c05/attachment.sig 


More information about the KMyMoney-devel mailing list