最近学习Qt 自定义绘画时碰到两个问题,问题如下:
自定义绘画图形,采用重写QPaintEvent,发现绘画不起作用;
1、Qpainter不刷新,解决方法:在触发刷新是,调用updata()函数强行更新。
问题
其中Qpainter 的父类应该是具体绘画的widget;
对于QGraphiscView:我所碰到的问题如下:
输出:
QPainter::fillPath: Painter not active
QPainter::setPen: Painter not active
QPainter::restore: Unbalanced save/restore
QWidget::paintEngine: Should no longer be called
QPainter::begin: Paint device returned engine == 0, type: 1
QPainter::setRenderHint: Painter must be active to set rendering hints
QPainter::save: Painter not active
QPainter::translate: Painter not active
QPainter::setPen: Painter not active
void ViewPager::paintEvent(QPaintEvent *e)
{
QPainter painter(this)