1. 程式人生 > >Qt中重繪制窗口方法:

Qt中重繪制窗口方法:

get spa style () time color ack == brush

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