#include "gui.h" #include "ui_gui.h" #include "recruitmentscene.h" #include GUI::GUI(QWidget *parent) : QMainWindow(parent, Qt::Window | Qt::FramelessWindowHint), ui_(new Ui::GUI), dx_(0), dy_(0) { ui_->setupUi(this); rq_scene_ = new RecruitmentScene(ui_->main_content_); /// Инициализируем графическую сцену rq_scene_->show(); //rq_scene_->hide(); } GUI::~GUI() { delete ui_; } void GUI::mouseMoveEvent( QMouseEvent* e ) { if( e->buttons() | Qt::LeftButton ) { QPoint pt=mapFromGlobal(QCursor::pos()); QWidget* child=childAt(pt); if (child == 0) { setGeometry(pos().x() + (pt.x() - dx_ ), pos().y() + (pt.y() - dy_ ), width(), height()); // dx_ = pt.x(); // dy_ = pt.y(); return; } QString cname = child->metaObject()->className(); if (cname != "QPushButton" && cname != "QComboBox"){ // отключаем перетягивание при наведение на активные элементы setGeometry(pos().x() + ( pt.x() - dx_ ), pos().y() + ( pt.y() - dy_ ), width(), height()); } else { dx_ = pt.x(); dy_ = pt.y(); } } } void GUI::mousePressEvent( QMouseEvent* e ) { if( e->button() == Qt::LeftButton ) { QPoint pt=mapFromGlobal(QCursor::pos()); dx_ = pt.x(); dy_ = pt.y(); setCursor( Qt::OpenHandCursor ); } } void GUI::mouseReleaseEvent( QMouseEvent* e ) { if( e->button() == Qt::LeftButton ) { QPoint pt=mapFromGlobal(QCursor::pos()); setCursor( Qt::ArrowCursor ); dx_ = pt.x(); dy_ = pt.y(); } }