Foo Bar - 2003-04-07

hi,

i have a stupid question ;)

why my Qt::CanvasRectangle isn't drawn ;(

--- cut

package myCanvasView;

use strict;
use Qt;
use Qt::isa qw(Qt::CanvasView);
#use Qt::signals
#;
#use Qt::slots
#;
use Qt::attributes qw(
    pixmap
    canvas
    rec
    cpItem
);

sub NEW {
    shift->SUPER::NEW(@_);

    #-- load pixmap for canvas background
    pixmap = Qt::Pixmap('test.png');
    if ( pixmap->isNull() ) {
        die "Oops, image test.png not found\n";
    }
   
    #-- canvas with background image
    canvas  = Qt::Canvas(this, 'canvas');
        canvas->setBackgroundPixmap(pixmap);
        canvas->resize( pixmap->width(), pixmap->height() );

        this->_drawTextArea();
       
    this->setCanvas(canvas);
}

sub sizePolicy {
    Qt::SizePolicy(&Qt::SizePolicy::Expanding, &Qt::SizePolicy::Expanding);
}

sub _drawTextArea {
    rec = Qt::CanvasRectangle ( 10, 10, 50, 50, canvas );
    #cpItem = Qt::CanvasPolygonalItem( canvas );
    rec->setBrush( Qt::Brush( Qt::Color(255, 0, 0)) );
    rec->setPen( Qt::Pen(Qt::Color(255, 0, 0)) );
    canvas->update();
}

1;