[Kmymoney-devel] Re: kMyMoneyAccountSelector - Q_PROPERTY

Cristian Oneţ onet.cristian at gmail.com
Fri Oct 15 10:05:46 CEST 2010


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/classKConfigDialogManager.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.

Regards,
Cristian

P.S: Petr sorry for the extra mail I've forgot to post to the list also


More information about the KMyMoney-devel mailing list