Qt中重绘制窗口方法:
Posted 唯一诺
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Qt中重绘制窗口方法:相关的知识,希望对你有一定的参考价值。
1 void CircleWidget::paintEvent(QPaintEvent * event) 2 { 3 QPainter painter(this); 4 5 int wight = this->width(); 6 int heigth = this->height(); 7 8 if (m_timers==0) 9 { 10 11 QColor green(0, 0, 0xff); 12 QPen pen(green); 13 14 painter.setBrush(QBrush(QColor(0x00, 0xFF, 0x00))); 15 pen.setStyle(Qt::DashLine); 16 painter.setPen(pen); 17 m_timers++; 18 } 19 else 20 { 21 22 23 QColor red(0xff,0 ,0); 24 QPen pen(red); 25 26 painter.setBrush(QBrush(QColor(0xFF,0x00,0x00))); 27 pen.setStyle(Qt::DashLine); 28 painter.setPen(pen); 29 m_timers = 0; 30 } 31 painter.drawRect(0, 0, 100, 100); 32 } 33 34 void CircleWidget::timerEvent(QTimerEvent* event) 35 { 36 if (event->timerId() == m_TimerID) 37 { 38 update(); 39 } 40 }
以上是关于Qt中重绘制窗口方法:的主要内容,如果未能解决你的问题,请参考以下文章