QT 最小化到托盘 和 关闭到托盘 的例子 [开源中国]

来源:互联网 发布:怎么进入淘宝客推广 编辑:程序博客网 时间:2024/06/05 00:28

01 //关闭到托盘--------- 

02 void Widget::closeEvent(QCloseEvent *e) 

03 { 

04     e->ignore(); 

05     this->hide(); 

06 } 

07   

08   

09 //最小化到托盘---- 

10 void Widget::changeEvent(QEvent *e) 

11 { 

12     if((e->type()==QEvent::WindowStateChange)&&this->isMinimized()) 

13     { 

             //定时器单次有效,只计时一次而不重复计时

14         QTimer::singleShot(100, this, SLOT(close())); 

15     } 

16 }

原创粉丝点击