由于qt自带的标题栏太丑了,必须把标题栏隐藏掉。
使用如下语句可以隐藏标题栏:
this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint);
如何实现通过鼠标移动无标题栏的窗体:
1.头文件:
#include "qevent.h"
2. 在h文件中申明:
bool eventFilter(QObject *watched, QEvent *evt);
3.在窗体初始化时,安装事件过滤器:
this->installEventFilter(this);
4.鼠标事件:
//移动窗体 bool welcomeform::eventFilter(QObject *watched, QEvent *evt) { static QPoint mousePoint; static bool mousePressed = false;
QMouseEvent *event = static_cast<QMouseEvent *>(evt);
if (event->type() == QEvent::MouseButtonPress) {
if (event->button() == Qt::LeftButton) {
mousePressed =