GUIFormBaseDialog, a useful base class for form edit
This commit is contained in:
41
src/GUIFormBaseDialog.cpp
Normal file
41
src/GUIFormBaseDialog.cpp
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
//
|
||||||
|
// Created by Krad on 2021/11/10.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "GUIFormBaseDialog.h"
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QPushButton>
|
||||||
|
GUIFormBaseDialog::GUIFormBaseDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) {
|
||||||
|
this->setObjectName("formDialog");
|
||||||
|
this->setWindowFlags (Qt :: FramelessWindowHint | Qt :: Dialog);
|
||||||
|
this->setFixedSize(500,600);
|
||||||
|
this->formWidget = new QWidget(this);
|
||||||
|
this->formWidget->setObjectName("formWidget");
|
||||||
|
|
||||||
|
QVBoxLayout* vLayout = new QVBoxLayout(this);
|
||||||
|
// vLayout->setContentsMargins(680,100,680,100);
|
||||||
|
vLayout->addWidget(formWidget);
|
||||||
|
|
||||||
|
QWidget* btnWidget= new QWidget(this);
|
||||||
|
vLayout->addWidget(btnWidget);
|
||||||
|
QHBoxLayout* hLayout = new QHBoxLayout(btnWidget);
|
||||||
|
QPushButton* btnOk= new QPushButton(btnWidget);
|
||||||
|
btnOk->setText("OK");
|
||||||
|
QPushButton* btnCancel = new QPushButton(btnWidget);
|
||||||
|
btnCancel->setText("Cancel");
|
||||||
|
hLayout->addWidget(btnOk);
|
||||||
|
hLayout->addWidget(btnCancel);
|
||||||
|
btnOk->setObjectName("btnOK");
|
||||||
|
connect(btnOk, &QPushButton::clicked, [t=this](){
|
||||||
|
if(t->updateReferenceData())
|
||||||
|
t->accept();
|
||||||
|
});
|
||||||
|
connect(btnCancel, &QPushButton::clicked, [t=this](){
|
||||||
|
t->reject();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
GUIFormBaseDialog::~GUIFormBaseDialog() {
|
||||||
|
|
||||||
|
}
|
||||||
23
src/GUIFormBaseDialog.h
Normal file
23
src/GUIFormBaseDialog.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
//
|
||||||
|
// Created by Krad on 2021/11/10.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef GUI_GUIFORMBASEDIALOG_H
|
||||||
|
#define GUI_GUIFORMBASEDIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
class GUIFormBaseDialog: public QDialog {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit GUIFormBaseDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
|
||||||
|
~GUIFormBaseDialog();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool updateReferenceData(){
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
QWidget* formWidget = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //GUI_GUIFORMBASEDIALOG_H
|
||||||
Reference in New Issue
Block a user