代码拉取完成,页面将自动刷新
同步操作将从 clickto/Qt-FramelessWindow 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "MainWindowSample.h"
#include "DialogSample.h"
MainWindowSample::MainWindowSample(QWidget* parent)
: FramelessWindow<QMainWindow>(true, parent)
{
setupUi();
setTitlebar({widgetTitle_, labelTitle_});
setResizeable(true);
loadStyleSheetFile(":/QtFramelessWindowSample/Resources/main.css", this);
connect(pushButtonClose_, &QPushButton::clicked, [this]() { this->close(); });
connect(pushButtonDialog_, &QPushButton::clicked, [this]() {
DialogSample* pWnd = new DialogSample(this);
pWnd->setResizeable(false);
pWnd->setModal(true);
pWnd->show();
});
connect(pushButtonResizableDialog_, &QPushButton::clicked, [this]() {
DialogSample* pWnd = new DialogSample(this);
pWnd->setResizeable(true);
pWnd->setModal(true);
pWnd->show();
});
}
void MainWindowSample::resizeEvent(QResizeEvent* event) {
labelTitle_->setText(QString("Frameless Window (Title Height: %1px)").arg(widgetTitle_->height()));
pushButtonH_->setText(QString::number(pushButtonH_->width()));
pushButtonV_->setText(QString::number(pushButtonV_->height()));
QMainWindow::resizeEvent(event);
}
void MainWindowSample::setupUi() {
this->setObjectName("FramelessWnd");
widgetCentral_ = new QWidget();
widgetCentral_->setObjectName("widgetCentral");
widgetTitle_ = new QWidget();
widgetTitle_->setObjectName("widgetTitle");
labelTitle_ = new QLabel();
labelTitle_->setObjectName("labelTitle");
labelTitle_->setText("Frameless Window");
pushButtonClose_ = new QPushButton();
pushButtonClose_->setObjectName("pushButtonClose");
pushButtonClose_->setCursor(QCursor(Qt::PointingHandCursor));
pushButtonClose_->setFixedSize(30, 30);
pushButtonH_ = new QPushButton();
pushButtonH_->setObjectName("pushButtonH");
pushButtonH_->setText("--");
pushButtonH_->setCursor(QCursor(Qt::PointingHandCursor));
pushButtonH_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
pushButtonH_->setFixedHeight(30);
pushButtonV_ = new QPushButton();
pushButtonV_->setObjectName("pushButtonV");
pushButtonV_->setText("--");
pushButtonV_->setCursor(QCursor(Qt::PointingHandCursor));
pushButtonV_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
pushButtonV_->setFixedWidth(30);
pushButtonDialog_ = new QPushButton();
pushButtonDialog_->setObjectName("pushButtonDialog");
pushButtonDialog_->setText("Dialog");
pushButtonDialog_->setCursor(QCursor(Qt::PointingHandCursor));
pushButtonDialog_->setFixedSize(80, 26);
pushButtonResizableDialog_ = new QPushButton();
pushButtonResizableDialog_->setObjectName("pushButtonResizableDialog");
pushButtonResizableDialog_->setText("Resizable Dialog");
pushButtonResizableDialog_->setCursor(QCursor(Qt::PointingHandCursor));
pushButtonResizableDialog_->setFixedSize(160, 26);
QHBoxLayout* hlTitle = new QHBoxLayout();
hlTitle->setContentsMargins(10, 0, 10, 0);
hlTitle->setSpacing(0);
hlTitle->addWidget(labelTitle_);
hlTitle->addStretch(2);
hlTitle->addWidget(pushButtonDialog_);
hlTitle->addStretch(1);
hlTitle->addWidget(pushButtonClose_);
widgetTitle_->setLayout(hlTitle);
widgetTitle_->setFixedHeight(30);
QGridLayout* gridBody = new QGridLayout();
gridBody->setSpacing(0);
gridBody->setContentsMargins(0, 0, 0, 0);
gridBody->addWidget(pushButtonResizableDialog_, 0, 0, Qt::AlignCenter);
gridBody->addWidget(pushButtonH_, 1, 0, 1, 3, Qt::AlignVCenter);
gridBody->addWidget(pushButtonV_, 0, 2, 3, 1, Qt::AlignHCenter);
QVBoxLayout* hlCenteral = new QVBoxLayout();
hlCenteral->setSpacing(0);
hlCenteral->setContentsMargins(2, 2, 2, 2); // 2px border
hlCenteral->addWidget(widgetTitle_);
hlCenteral->addLayout(gridBody);
widgetCentral_->setLayout(hlCenteral);
this->setCentralWidget(widgetCentral_);
this->setMinimumSize(800, 600);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。