asdf
26th May 2010, 18: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?
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?