• 4157阅读
  • 2回复

关于绘图的效率问题 [复制链接]

上一主题 下一主题
离线溟阡
 
只看楼主 倒序阅读 楼主  发表于: 2009-06-22
用QGraphicsScene和QGraphicsView绘图时,需要画很多点
所以在for循环里用addEllipse来画
但是每个点的颜色都有所不同,所以把颜色计算好之后存入list中,画的时候从list中取出来
但是画的很慢,要好几秒才能出来
有没有什么办法可以解决这个问题啊?
只看该作者 1楼 发表于: 2009-06-22
void QCoreApplication::processEvents ( QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents )   [static]
Processes all pending events for the calling thread according to the specified flags until there are no more events to process.
You can call this function occasionally when your program is busy performing a long operation (e.g. copying a file).
In event you are running a local loop which calls this function continuously, without an event loop, the DeferredDelete events will not be processed. This can affect the behaviour of widgets, e.g. QToolTip, that rely on DeferredDelete events to function properly. An alternative would be to call sendPostedEvents() from within that local loop.
Calling this function processes events only for the calling thread.
Note: This function is thread-safe.
See also exec(), QTimer, QEventLoop::processEvents(), flush(), and sendPostedEvents().
离线溟阡
只看该作者 2楼 发表于: 2009-06-22
没太明白楼上的意思……
快速回复
限100 字节
 
上一个 下一个