[PyQt] Painting an arc... can't be that hard?

Paul A. Giannaros paul at giannaros.org
Fri Sep 5 21:06:11 BST 2008

On Fri, Sep 5, 2008 at 7:47 PM, Scott Price <scottmprice at gmail.com> wrote:
> So, using PyQt4/WindowsXP:
> I'm attempting to adapt the basic drawing example for the simple purpose of
> drawing an arc on the background of a widget.  The following code opens a
> main window with a child widget inside, but doesn't draw the arc.  Probably
> something simple that I'm missing, but I can't spot it... My eyes are
> crossing from reading the documentation and attempting different things.
> What have I missed?

It's a fairly subtle one. You need to understand that the typical use
of QScrollArea is for displaying a large widget in a scrollable area; it
assumes that the widget that you give it (via setWidget) will have a
size already. Refer to the QScrollArea documentation[1] to see what
I mean. To overcome the problem, you can tell the scroll area that
it should resize its widget to fill up the available space itself by
using the setWidgetResizable function.
Therefore, adding the following line after you create the dialog will make
things work:


You can also get rid of the scroll area if you don't need it and just
call setCentralWidget on your groupDialog class.
You could also have done away with the main window altogether
and set mainwindow = GroupDialog() in your main block.


[1] http://doc.trolltech.com/4.4/qscrollarea.html

More information about the PyQt mailing list