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

List:       pykde
Subject:    Re: [PyKDE] QSqlPropertyMap
From:       Phil Thompson <phil () riverbankcomputing ! co ! uk>
Date:       2004-02-24 21:59:18
Message-ID: 200402242159.18155.phil () riverbankcomputing ! co ! uk
[Download RAW message or body]

On Tuesday 24 February 2004 21:12, Torsten Bielen wrote:
> Hi,
>
> I want to use my own QSqlPropertyMap in a form to install a customized
> editor. Is there any example how to use QSqlPropertyMap in python. I wrote
> the code below but it doesn't work.
>
> class IdEditor(QWidget):
>    """
>    custom editor for a combo box (without any functionality yet)
>    """
>     def __init__(self, cmbBox):
>         QWidget.__init__(self)
>         self.cmbBox = cmbBox
>         self._itemId = 0
>
>     def itemId(self):
>         debug("itemId called")
>     def setItemId(self, id):
>         debug("setItemId called")
>
>
> ... ...
>         self.sqlPropMap = QSqlPropertyMap()
>         self.sqlPropMap.insert("IdEditor", "itemId")
>         self.sqlForm = QSqlForm(self, "frmAccount_SqlForm")
>         self.sqlForm.installPropertyMap(self.sqlPropMap)
>
>         self.sqlForm.insert(self.lineEditLoginName, "login_name")
>         self.sqlForm.insert(self.lineEditFullName, "full_name")
>         self.sqlForm.insert(self.checkBoxLocked , "locked")
>         self.sqlForm.insert(self.textEditDesc, "long_desc")
>         self.sqlForm.insert(IdEditor(self.comboBoxPrimaryGroup),
> 					"primary_group")
>
> In the form is a combo box. I want to translate ids stored in the database
> into strings (group names). My idea was to wrap the combo box with my own
> editor and translate it to strings stored in the combo box.

An obvious problem is that the IdEditor instance will get garbage collected 
immediately. Try keeping another reference to it.

Phil

_______________________________________________
PyKDE mailing list    PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[prev in list] [next in list] [prev in thread] [next in thread] 

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