Qt画家不更新
Qt Painter don't update
我需要绘制简单的矩形,但当我调用update()函数时,它不做任何事情。下面是我的代码:
...//this is called when button is pressed, when application loads nothing should be drawn.
draw = true;
update();
}
void MainWindow::paintEvent(QPaintEvent *e){
QPainter painter(this);
QLinearGradient lg(QPoint(20, 80), QPoint(215, 390));
lg.setColorAt(0, Qt::white);
lg.setColorAt(1, Qt::blue);
QBrush brush(lg);
painter.setPen(Qt::black);
painter.setBrush(brush);
if(draw == true){
painter.drawRect(20, 80, 195, 300);
}
}
您应该尝试添加
e->accept()
相关文章:
- 从C++本机插件更新Vector3数组
- QGraphicsPolygonItem在拖动时未更新QPolygonF坐标
- cmake更新缓存的变量
- flutter:即使shouldRepaint()返回true,自定义画家也不会重新绘制
- 更新到莫哈韦后出现cmath错误
- OpenMP:并行更新数组总是需要减少数组吗
- 为什么我的变量没有更新,我的 LED 没有亮起?
- 指针没有更新它在void函数内部指向的值
- 如何在c++中获取要更新的值
- 已修改的LinkedList未在文本文件本身中更新
- Qt:当QListView获得新条目时,如何更新QStringList
- 更新的矢量元素不打印
- 如何使用按钮更新GTK3图像以使用C++从相机捕获图片
- 如何在ECS框架中更新组件数据和通知系统
- 从VS 2015更新3更新到VS2015更新3 d后浮点计算行为不同的原因
- 如果我想在没有更新编译器的情况下使用新功能,该怎么办?
- 如何在 C++11 中查找和更新向量中的一个嵌套结构
- (SFML)按下键时,播放器构造函数未使用正确的动画进行更新
- 在 emscripten 网页汇编正在运行期间更新进度条?
- Qt画家不更新