首页 > 其他 > 详细

Qt中重绘制窗口方法:

时间:2017-09-21 21:40:50      阅读:275      评论:0      收藏:0      [点我收藏+]
 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中重绘制窗口方法:

原文:http://www.cnblogs.com/weiyouqing/p/7571414.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!