[PyQt] Creating custom widget for designer
Florian Bruhin
me at the-compiler.org
Fri Aug 29 08:41:48 BST 2014
Hi,
* Jorge Tornero <jtorlistas at gmail.com> [2014-08-21 04:59:10 +0200]:
> Dear all,
> I've created a custom widget which can be used from within designer-qt4,
> following the few recipes available out there.
>
> It works as expected but, because I'm not a pro, I'm looking for some
> advice on the way I've implemented the widget.
>
> Basically: the base class is a QLineEdit in which a key event triggers a
> Qdialog which has customized QComboBox inside. Therefore I've implemented
> the widget as a single class in this fashion (simplified)
>
> class myLineEdit(QLineEdit):
> class myPopupDialog(QDialog):
>
> class myCustomCombo(QComboBox):
> (Definition of myCustomCombo goes here)
> (Definition of mypopupdialog goes here, including some customcombos)
>
> (Defi ition of mylineedit goes here including key event handler
> that execs a mypopupdialog)
>
> This, say so, class-!nesting schema is very strange to me, so let me
> ask you if this is a correct way of implementing such widgets,
> providing they're going to be used as designer plugins.
>
> Thank you very much for your advice
I don't know anything about designer plugins, so this is more from the
general Python perspective:
This certainly works - I sometimes use it for small helper functions.
It seems like it works fine with classes as well.
However, IMHO it would be cleaner to just define multiple classes in a
module, all on the toplevel, like this:
class myCustomCombo(QComboBox):
(Definition of myCustomCombo goes here)
class myPopupDialog(QDialog):
(Definition of mypopupdialog goes here, including some
customcombos)
class myLineEdit(QLineEdit):
(Definition of mylineedit goes here including key event handler
that execs a mypopupdialog)
Florian
--
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
GPG 0xFD55A072 | http://the-compiler.org/pubkey.asc
I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20140829/39b51533/attachment.sig>
More information about the PyQt
mailing list