#include "quiwidget.h"
QUIWidget::QUIWidget(QWidget *parent) : QDialog(parent)
{
this->initControl();
this->initForm();
}
QUIWidget::~QUIWidget()
{
delete widgetMain;
}
bool QUIWidget::eventFilter(QObject *obj, 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 = true;
mousePoint = event->globalPos() - this->pos();
return true;
}
} else if (event->type() == QEvent::MouseButtonRelease) {
mousePressed = false;
return true;
} else if (event->type() == QEvent::MouseMove) {
if (mousePressed && (event->buttons() && Qt::LeftButton)) {
this->move(event->globalPos() - mousePoint);
return true;
}
} else if (event->type() == QEvent::MouseButtonDblClick) {
//以下写法可以将双击识别限定在标题栏
//if (this->btnMenu_Max->isVisible() && obj == this->widgetTitle) {
if (this->btnMenu_Max->isVisible()) {
this->on_btnMenu_Max_clicked();
return true;
}
}
return QWidget::eventFilter(obj, evt);
}
QLabel *QUIWidget::getLabIco() const
{
return this->labIco;
}
QLabel *QUIWidget::getLabTitle() const
{
return this->labTitle;
}
QToolButton *QUIWidget::getBtnMenu() const
{
return this->btnMenu;
}
QPushButton *QUIWidget::getBtnMenuMin() const
{
return this->btnMenu_Min;
}
QPushButton *QUIWidget::getBtnMenuMax() const
{
return this->btnMenu_Max;
}
QPushButton *QUIWidget::getBtnMenuMClose() const
{
return this->btnMenu_Close;
}
QString QUIWidget::getTitle() const
{
return this->title;
}
Qt::Alignment QUIWidget::getAlignment() const
{
return this->alignment;
}
QSize QUIWidget::sizeHint() const
{
return QSize(600, 450);
}
QSize QUIWidget::minimumSizeHint() const
{
return QSize(200, 150);
}
void QUIWidget::initControl()
{
this->setObjectName(QString::fromUtf8("QUIWidget"));
this->resize(900, 750);
verticalLayout1 = new QVBoxLayout(this);
verticalLayout1->setSpacing(0);
verticalLayout1->setContentsMargins(11, 11, 11, 11);
verticalLayout1->setObjectName(QString::fromUtf8("verticalLayout1"));
verticalLayout1->setContentsMargins(1, 1, 1, 1);
widgetMain = new QWidget(this);
widgetMain->setObjectName(QString::fromUtf8("widgetMain"));
verticalLayout2 = new QVBoxLayout(widgetMain);
verticalLayout2->setSpacing(0);
verticalLayout2->setContentsMargins(11, 11, 11, 11);
verticalLayout2->setObjectName(QString::fromUtf8("verticalLayout2"));
verticalLayout2->setContentsMargins(0, 0, 0, 0);
widgetTitle = new QWidget(widgetMain);
widgetTitle->setObjectName(QString::fromUtf8("widgetTitle"));
QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(widgetTitle->sizePolicy().hasHeightForWidth());
widgetTitle->setSizePolicy(sizePolicy);
widgetTitle->setMinimumSize(QSize(0, 30));
horizontalLayout4 = new QHBoxLayout(widgetTitle);
horizontalLayout4->setSpacing(0);
horizontalLayout4->setContentsMargins(11, 11, 11, 11);
horizontalLayout4->setObjectName(QString::fromUtf8("horizontalLayout4"));
horizontalLayout4->setContentsMargins(0, 0, 0, 0);
labIco = new QLabel(widgetTitle);
labIco->setObjectName(QString::fromUtf8("labIco"));
QSizePolicy sizePolicy1(QSizePolicy::Minimum, QSizePolicy::Preferred);
sizePolicy1.setHorizontalStretch(0);
sizePolicy1.setVerticalStretch(0);
sizePolicy1.setHeightForWidth(labIco->sizePolicy().hasHeightForWidth());
labIco->setSizePolicy(sizePolicy1);
labIco->setMinimumSize(QSize(30, 0));
labIco->setAlignment(Qt::AlignCenter);
horizontalLayout4->addWidget(labIco);
labTitle = new QLabel(widgetTitle);
labTitle->setObjectName(QString::fromUtf8("labTitle"));
QSizePolicy sizePolicy2(QSizePolicy::Expanding, QSizePolicy::Preferred);
sizePolicy2.setHorizontalStretch(0);
sizePolicy2.setVerticalStretch(0);
sizePolicy2.setHeightForWidth(labTitle->sizePolicy().hasHeightForWidth());
labTitle->setSizePolicy(sizePolicy2);
labTitle->setAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignVCenter);
horizontalLayout4->addWidget(labTitle);
widgetMenu = new QWidget(widgetTitle);
widgetMenu->setObjectName(QString::fromUtf8("widgetMenu"));
sizePolicy1.setHeightForWidth(widgetMenu->sizePolicy().hasHeightForWidth());
widgetMenu->setSizePolicy(sizePolicy1);
horizontalLayout = new QHBoxLayout(widgetMenu);
horizontalLayout->setSpacing(0);
horizontalLayout->setContentsMargins(11, 11, 11, 11);
horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
horizontalLayout->setContentsMargins(0, 0, 0, 0);
btnMenu = new QToolButton(widgetMenu);
btnMenu->setObjectName(QString::fromUtf8("btnMenu"));
QSizePolicy sizePolicy3(QSizePolicy::Fixed, QSizePolicy::Expanding);
sizePolicy3.setHorizontalStretch(0);
sizePolicy3.setVerticalStretch(0);
sizePolicy3.setHeightForWidth(btnMenu->sizePolicy().hasHeightForWidth());
btnMenu->setSizePolicy(sizePolicy3);
btnMenu->setMinimumSize(QSize(30, 0));
btnMenu->setMaximumSize(QSize(30, 16777215));
btnMenu->setFocusPolicy(Qt::NoFocus);
btnMenu->setPopupMode(QToolButton::InstantPopup);
horizontalLayout->addWidget(btnMenu);
btnMenu_Min = new QPushButton(widgetMenu);
btnMenu_Min->setObjectName(QString::fromUtf8("btnMenu_Min"));
QSizePolicy sizePolicy4(QSizePolicy::Minimum, QSizePolicy::Expanding);
sizePolicy4.setHorizontalStretch(0);
sizePolicy4.setVerticalStretch(0);
sizePolicy4.setHeightForWidth(btnMenu_Min->sizePolicy().hasHeightForWidth());
btnMenu_Min->setSizePolicy(sizePolicy4);
btnMenu_Min->setMinimumSize(QSize(30, 0));
btnMenu_Min->setMaximumSize(QSize(30, 16777215));
btnMenu_Min->setCursor(QCursor(Qt::ArrowCursor));
btnMenu_Min->setFocusPolicy(Qt::NoFocus);
horizontalLayout->addWidget(btnMenu_Min);
btnMenu_Max = new QPushButton(widgetMenu);
btnMenu_Max->setObjectName(QString::fromUtf8("btnMenu_Max"));
sizePolicy3.setHeightForWidth(btnMenu_Max->sizePolicy().hasHeightForWidth());
btnMenu_Max->setSizePolicy(sizePolicy3);
btnMenu_Max->setMinimumSize(QSize(30, 0));
btnMenu_Max->setMaximumSize(QSize(30, 16777215));
btnMenu_Max->setCursor(QCursor(Qt::ArrowCursor));
btnMenu_Max->setFocusPolicy(Qt::NoFocus);
horizontalLayout->addWidget(btnMenu_Max);
btnMenu_Close = new QPushButton(widgetMenu);
btnMenu_Close->setObjectName(QString::fromUtf8("btnMenu_Close"));
sizePolicy3.setHeightForWidth(btnMenu_Close->sizePolicy().hasHeightForWidth());
btnMenu_Close->setSizePolicy(sizePolicy3);
btnMenu_Close->setMinimumSize(QSize(30, 0));
btnMenu_Close->setMaximumSize(QSize(30, 16777215));
btnMenu_Close->setCursor(QCursor(Qt::ArrowCursor));
btnMenu_Close->setFocusPolicy(Qt::NoFocus);
horizontalLayout->addWidget(btnMenu_Close);
horizontalLayout4->addWidget(widgetMenu);
verticalLayout2->addWidget(widgetTitle);
widget = new QWidget(widgetMain);
widget->setObjectName(QString::fromUtf8("widget"));
verticalLayout3 = new QVBoxLayout(widget);
verticalLayout3->setSpacing(0);
verticalLayout3->setContentsMargins(11, 11, 11, 11);
verticalLayout3->setObjectName(QString::fromUtf8("verticalLayout3"));
verticalLayout3->setContentsMargins(0, 0, 0, 0);
verticalLayout2->addWidget(widget);
verticalLayo