小编Bar*_* El的帖子

使用 Qt 在 QGraphicsScene 中画线

我画线有问题。当鼠标移动缓慢时效果很好,但是当鼠标移动得更快时,会出现一些间隙,我不知道为什么。这是代码:

if(QEvent::MouseButtonPress&&event->buttons()==Qt::LeftButton){
QPointF pt=mapToScene(event->pos());
        band->setGeometry(0,0,0,0);
         band->hide();
        band->update();
         this->scene()->addLine(pt.x(),pt.y(),pt.x(),pt.y(),QPen(color, size));
    qDebug()<<event->pos();
}
Run Code Online (Sandbox Code Playgroud)

这是一个屏幕截图:

在此处输入图片说明

左边画得慢,右边画得快。

qt mousepress qgraphicsscene

4
推荐指数
1
解决办法
4510
查看次数

标签 统计

mousepress ×1

qgraphicsscene ×1

qt ×1