码迷,mamicode.com
首页 > 其他好文 > 详细

Qt中重绘制窗口方法:

时间:2017-09-21 21:44:55      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:style   ack   das   drawrect   lin   line   重绘   class   round   

 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中重绘制窗口方法:

标签:style   ack   das   drawrect   lin   line   重绘   class   round   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!