[PyQt] Custom Widget

Fernando Cosso ferdemza at gmail.com
Thu Jan 27 23:37:42 GMT 2011


In the end I was able to integrate the widget to Qt Designer

I added some more stuff to the widget class and I remove the
reimplementation of text() and setText(). I wanted a rich text button
without the other text property.

I could not hide the text property to Qt Designer though

I have attached what I have now

Best Regards

On 27 January 2011 18:13, Hans-Peter Jansen <hpj at urpla.net> wrote:

> On Thursday 27 January 2011, 05:19:12 Fernando Cosso wrote:
> > Many Thanks Pete
> >
> > I forgot to answer back, but eventually I did convert the code from
> > C++ to Python
> >
> > I could solve the crash issue doing this:
> >
> >            richTextLabel.drawContents(QPainter(richTextPixmap),
> > QRectF(richTextPixmap.rect()))
>
> Hey, I like this better than what Phil suggested.
>
> > I am fighting now with Qt Designer. I am trying to put the Html
> > property in the Property editor panel as a rich Text Property, but no
> > luck.
> >
> > I am trying to get the right xml on the method domXml of the class
> > QtDesigner.QPyDesignerCustomWidgetPlugin
>
> Send it over, what you have now, and I will look, if I can do something
> about.. I would add it to the example, that I plan to send over to
> Phil, if you don't mind.
>
> Pete
>
> > (
> > http://trinity.pearsoncomputing.net/docs/qt4/designer-creating-custom
> >-widgets.html )
> >
> >
> > Best Regards
> >
> > On 26 January 2011 22:03, Hans-Peter Jansen <hpj at urpla.net> wrote:
> > > On Wednesday 26 January 2011, 14:35:35 ferdemza at gmail.com wrote:
> > > > Thanks again Pete
> > > >
> > > > I think i will do my own custom widget from scratch following a
> > > > book i have and then use the link you gave me to integrate it to
> > > > the designer.
> > >
> > > As I told you, it is simpler to convert the Qt code.
> > >
> > > @Phil: for some reason, the richTextPainter.end() is needed in the
> > > PyQt version to avoid a SIGSEGV crash during paint event:
> > >
> > > QPaintDevice: Cannot destroy paint device that is being painted
> > >
> > > (gdb) bt
> > > #0  0x08339d10 in ?? ()
> > > #1  0xb647c3f8 in ~QPainter (this=0x1) at
> > > painting/qpainter.cpp:1491 #2  0xb6fdfe80 in release_QPainter
> > > (sipCppV=0x82514d8) at
> > > sipQtGuiQPainter.cpp:5371
> > > #3  0xb6fdfedc in dealloc_QPainter (sipSelf=0xb4ae4454) at
> > > sipQtGuiQPainter.cpp:5382
> > > #4  0xb7fc4f5f in forgetObject (sw=0xb4ae4454) at siplib.c:10004
> > > #5  0xb7fc4ff1 in sipSimpleWrapper_dealloc (self=0xb4ae4454) at
> > > siplib.c:9233
> > > #6  0xb7eba68d in subtype_dealloc (self=0xb4ae4454) at
> > > Objects/typeobject.c:1018
> > > #7  0xb7e8c24a in frame_dealloc (f=0x8301c4c) at
> > > Objects/frameobject.c:417 #8  0xb7ef8bec in PyEval_EvalCodeEx
> > > (co=0xb7c32260, globals=0xb7c7602c, locals=0x0, args=0xb7c42418,
> > > argcount=2,
> > >    kws=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at
> > > Python/ceval.c:2953
> > > #9  0xb7e8da29 in function_call (func=0xb5f37994, arg=0xb7c4240c,
> > > kw=0x0) at Objects/funcobject.c:524
> > > #10 0xb7e68c1c in PyObject_Call (func=0xb5f37994, arg=0xb7c4240c,
> > > kw=0x0) at Objects/abstract.c:2487
> > > #11 0xb7e769fe in instancemethod_call (func=0xb5f37994,
> > > arg=0xb7c4240c, kw=0x0) at Objects/classobject.c:2579
> > > #12 0xb7e68c1c in PyObject_Call (func=0xb7c26694, arg=0xb5f5b02c,
> > > kw=0x0) at Objects/abstract.c:2487
> > > #13 0xb7ef177f in PyEval_CallObjectWithKeywords (func=0xb7c26694,
> > > arg=0xb5f5b02c, kw=0x0) at Python/ceval.c:3548
> > > #14 0xb7fc6b03 in sip_api_call_method (isErr=0x0,
> > > method=0xb7c26694, fmt=0xb721cf4c "D") at siplib.c:1721
> > > #15 0xb6e3b5f9 in sipVH_QtGui_3 (sipGILState=PyGILState_UNLOCKED,
> > > sipMethod=0xb7c26694, a0=0xbfffdaa4)
> > >    at sipQtGuicmodule.cpp:7343
> > > #16 0xb7199dc9 in sipQPushButton::paintEvent (this=0x81f0718,
> > > a0=0xbfffdaa4) at sipQtGuiQPushButton.cpp:420
> > >
> > > Do you want me to prepare that code for inclusion into examples?
> > >
> > > Pete
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110127/e98c87bc/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: RPushButton.pyw
Type: application/octet-stream
Size: 4425 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110127/e98c87bc/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: RPushButtonPlugin.py
Type: application/octet-stream
Size: 2559 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110127/e98c87bc/attachment-0001.obj>


More information about the PyQt mailing list