update() or repaint() fails to trigger paintEvent()

十年热恋 提交于 2019-11-30 11:25:47
Abhiram

The solution is to call this->viewport()->repaint() or this->viewport()->update() from your QAbstractScrollArea derived class instead of just repaint() or update().

More info is given in Qt documentation:

QWidget * QAbstractScrollArea::viewport () const

Returns the viewport widget. Use the QScrollArea::widget() function to retrieve the contents of the viewport widget.

Since the contents that we have in our QAbstractScrollArea derived class will be displayed in the viewport widget, makes sense to call viewport widget's update or repaint to draw our data again (have our paintEvent called).

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!