PDA

View Full Version : problem with Qpainter being too slow (Maemo5)



asdf
26th May 2010, 19:00
Hi,

I have this problem with QPainter. I'm making widget that has many lines and dots. Problem is that it's realy slow.

I trying to make scrollable widget that's in QScrollArea. Here is a example picture how it looks on Maemo5:

http://i49.tinypic.com/2ikp98j.png

In mainwindow.cpp I have scrollArea and I put my widget in to it by:

PainterWidget *mypainterWidget = new PainterWidget(ui->scrollArea);
ui->verticalLayout->addWidget(mypainterWidget);

In PainterWidget I have paintEvent like this:

void PainterWidget::paintEvent(QPaintEvent *)
{

QPainter painter2(this);
painter2.setRenderHint(QPainter::Antialiasing, true);
painter2.setPen(QPen(Qt::white, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
QPainter painter3(this);
painter3.setRenderHint(QPainter::Antialiasing, true);
painter3.setPen(QPen(QColor(198,0,0,255), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));

QPainterPath path;

for(int i=0 ; i<30;i++){

if(i>0){
path.moveTo(col[i-1]+5, row[i-1]+5);
path.cubicTo(col[i-1]+5, row[i-1]+5, ((col[i-1]+col[i])/2), ((row[i-1]+row[i])/2), col[i], row[i]+5);

painter3.drawPath(path);

}

}


for(int i=0 ; i<30;i++){

painter.drawEllipse(col[i], row[i], 10, 10);

}

}



It's highly possible that I'm just doin something wrong here. Can someone help me with these information.

How can I make this to work faster?

asdf
27th May 2010, 18:32
Should I use some other kind of method?

Is it possible to draw image with QPainter and then set it into ScrollArea?

I have realy tried to make this work for a couple of days now but nothing works well.. :confused:

Talei
27th May 2010, 19:02
Probably this is not the best advice, and I don't know if it will speed things up (never programmed to Maemo5), but try to draw into QImage and then display that QImage.

asdf
28th May 2010, 01:07
Finally I found a solution.

painter2.setRenderHint(QPainter::Antialiasing, true); is too heavy to use. Now it woks fine.