[Kmymoney-devel] Re: kMyMoneyAccountSelector - Q_PROPERTY

Petr Bravenec petr at bravenec.org
Fri Oct 15 14:37:11 CEST 2010


Thanks. It works now. I do not want to touch KMyMoney sources so I extended 
kMyMoneyAccountSelector to my own class. Later the same I will do the same for 
kMyMoneyDateInput - now I use KDateWidget class where the Q_PROPERTY works. 

There is now only one disadvantage. The kMyMoneyAccountSelector is stored in 
libwidgets.a library so the object is staticaly linked in kmymoney and in my 
plugin, too. The kcm plugin is then more then five times bigger then kmm plugin 
itself. It would be better to have the kMyMoneyAccountSelector in shared 
library libkmm_widget.so.

Regards
Petr Bravenec

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.
> 
> Regards,
> Cristian
> 
> P.S: Petr sorry for the extra mail I've forgot to post to the list also
> _______________________________________________
> KMyMoney-devel mailing list
> KMyMoney-devel at kde.org
> https://mail.kde.org/mailman/listinfo/kmymoney-devel

-- 
Petr Bravenec
+420 777 566 384
petr at bravenec.org
http://bravenec.org/


More information about the KMyMoney-devel mailing list