[Development] how to double buffer for qt3

Leslie Zhai xiangzhai83 at gmail.com
Wed Oct 23 15:18:10 CEST 2013


Hi qt developers,

I know qt3 is too old, but there are some projects still developed by it.
I know how to use Xext double buffer
https://github.com/xiangzhai/myblog/blob/master/MTX11-Note/myxwin.cpp#L61 but
have no idea about qt3 for drawing ellipse with moving mouse`s position.

The source code shown as below:

void Qt3DbeBuf::mouseMoveEvent(QMouseEvent * me)
{
point_t point;
point.x = me->x();
point.y = me->y();
m_points.push_back(point);
update();
}

void Qt3DbeBuf::paintEvent(QPaintEvent * pe)
{
QRect rect(pe->rect());
QPixmap pixmap(rect.size());
pixmap.fill(this, 0, 0);
QPainter painter(this);
QPainter dbpainter(&pixmap);
int i;

dbpainter.translate(-rect.x(), -rect.y());
dbpainter.setBrush(Qt::white);

for (i = 0; i < m_points.size(); i++)
dbpainter.drawEllipse(m_points[i].x, m_points[i].y, 10, 10);

painter.drawPixmap(0, 0, &pixmap);
}

But it still flickr, maybe double buffer have no effect? Please some one
give me some advice, thanks a lot!

Best Regards,

Leslie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20131023/d72b853e/attachment.html>


More information about the Development mailing list