成都防火布,火炬之光有多少层,qq情侣文字头像
1 #ifndef customize_qwidget_h 2 #define customize_qwidget_h 3 #include <qwidget> 4 #include <qmouseevent> 5 6 class customizeqwidget : public qwidget 7 { 8 q_object 9 public: 10 explicit customizeqwidget(qwidget *parent = 0); 11 ~customizeqwidget(); 12 public slots: 13 void on_button_close_clicked(); 14 private: 15 void paintevent(qpaintevent *); 16 void mousepressevent(qmouseevent *event); 17 void mousemoveevent(qmouseevent *event); 18 private: 19 qpoint m_last_mouse_position; 20 }; 21 #endif // customize_qwidget_h
1 #include "customize_qwidget.h" 2 #include <qstyleoption> 3 #include <qpainter> 4 #include <qbrush> 5 6 customizeqwidget::customizeqwidget(qwidget *parent) 7 : qwidget(parent) 8 { 9 this -> setwindowflags(qt::framelesswindowhint); 10 } 11 12 customizeqwidget::~customizeqwidget() 13 { 14 } 15 16 void customizeqwidget::paintevent(qpaintevent *) 17 { 18 qstyleoption opt; 19 opt.init(this); 20 qpainter p(this); 21 style()->drawprimitive(qstyle::pe_widget, &opt, &p, this); 22 } 23 24 void customizeqwidget::mousepressevent(qmouseevent *event) 25 { 26 if(event->button() == qt::leftbutton) 27 { 28 m_last_mouse_position = event->globalpos(); 29 } 30 } 31 32 void customizeqwidget::mousemoveevent(qmouseevent *event) 33 { 34 if (!event->buttons().testflag(qt::leftbutton)) 35 return; 36 const qpoint position = pos() + event->globalpos() - m_last_mouse_position; //the position of mainfrmae + (current_mouse_position - last_mouse_position) 37 move(position.x(), position.y()); 38 m_last_mouse_position = event->globalpos(); 39 } 40 41 void customizeqwidget::on_button_close_clicked() 42 { 43 this->close(); 44 }
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Blazor server side 自家的一些开源的, 实用型项目的进度之 CEF客户端
.NET IoC模式依赖反转(DIP)、控制反转(Ioc)、依赖注入(DI)
vue+.netcore可支持业务代码扩展的开发框架 VOL.Vue 2.0版本发布
网友评论