class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
int _x;
int _y;
void mouseMoveEvent(QMouseEvent *e)
{
move(e->globalPos().x() -_x,e->globalPos().y() - _y);
}
void mousePressEvent(QMouseEvent *e)
{
/*不然会闪*/
_x = e->localPos().x();
_y = e->localPos().y();
}
private:
Ui::MainWindow *ui;
};
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->setWindowTitle("QT window");
this->setWindowFlags(Qt::FramelessWindowHint);
ui->pushButton->setText("Close");
this->connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(close()));
}
MainWindow::~MainWindow()
{
delete ui;
}