Gh0stR1der
18th April 2009, 04:13
Hi everybody out there using Qt4, I am doing a simple experiment using Qt4, I just wanna draw lines on a loaded image, here's the paintEvent code:
void GpsLocator::paintEvent(QPaintEvent *event){
image=new QImage();
image->load(*imageName);
windowPainter=new QPainter(this);
windowPainter->initFrom(this);
windowPainter->drawImage(0,0,*image);
this->setMinimumSize(image->width(),image->height());
imagePainter=new QPainter(image);
imagePainter->setPen(QPen(Qt::DotLine));
imagePainter->drawLine(218,223,433,375);
}
but this doesn't work, while the image is loaded successfully, but the line doesn't appear, I am just wondering how this could happen? Can anyone do me a favor, many thanks!
void GpsLocator::paintEvent(QPaintEvent *event){
image=new QImage();
image->load(*imageName);
windowPainter=new QPainter(this);
windowPainter->initFrom(this);
windowPainter->drawImage(0,0,*image);
this->setMinimumSize(image->width(),image->height());
imagePainter=new QPainter(image);
imagePainter->setPen(QPen(Qt::DotLine));
imagePainter->drawLine(218,223,433,375);
}
but this doesn't work, while the image is loaded successfully, but the line doesn't appear, I am just wondering how this could happen? Can anyone do me a favor, many thanks!