[PyKDE] Trouble figuring out QCanvas and QCanvasView
david at boddie.org.uk
Wed Oct 6 11:32:21 BST 2004
On Tue, 05 Oct 2004 23:28:39, Bryan O'Sullivan wrote:
> I am unable to figure out how to draw into a QCanvas and have it show up
> correctly in a QCanvasView. I've tried looking at both C++ and Python
> examples, but the examples are invariably so complex that it's
> impossible to figure out what is actually important.
That's disappointing to hear.
> I've attached the simple example I'm trying to make work. It ought to
> draw a diagonal black line, but nothing shows up. Clearly, I'm missing
> something, but neither the documentation nor the examples suggest what
> that might be.
I think that the problem is with the ownership of the QCanvas, although
it's very strange if that really is the case since you pass it to the
QCanvasView. I "fixed" your example so that it would work by giving the
QCanvas a parent when it is created. I've included the modified code below.
Hope this helps,
c = qtcanvas.QCanvas(self) # <- gives the canvas a parent QObject
v = qtcanvas.QCanvasView(self)
lay = qt.QVBoxLayout(self)
l = qtcanvas.QCanvasLine(c)
def __init__(self, args):
self.w = Widge()
app = App(sys.argv)
$0 Web Hosting with up to 120MB web space, 1000 MB Transfer
10 Personalized POP and Web E-mail Accounts, and much more.
Signup at www.doteasy.com
More information about the PyQt