#ifndef FUNCTION_GLOBAL_H #define FUNCTION_GLOBAL_H #include #include #include #include "DemoGallery/Tool.h" #include "component/Button.h" #include "component/ComboBox.h" #include "component/Input.h" #include "../Tree_Table.h" #include "../Table.h" extern QColor base; class FunctionWidget : public QWidget { public: QLabel* title{}; QLabel* explain{}; QVBoxLayout* layout{}; Button* btn{}; FunctionWidget() {} void init(const QString& title_text, const QString& explain_text, QLayout* l) { this->title = new QLabel(title_text); this->explain = new QLabel(explain_text); layout = new QVBoxLayout(this); layout->addLayout(create_line_1()); btn = new Button(); btn->content.text = new Text(QString("确定"), QPen(Qt::white)); layout->addLayout(l); // qDebug() << " btn->sizeHint() " << btn->sizeHint(); layout->addStretch(1); layout->addWidget(btn); btn->background.set_color(base); } QHBoxLayout* create_line_1() { auto ret = new QHBoxLayout; ret->addWidget(this->title, 1); ret->addWidget(this->explain, 1); return ret; } void paintEvent(QPaintEvent* event) override { QPainter painter(this); painter.setRenderHints(QPainter::Antialiasing); painter.setPen(Qt::NoPen); painter.setBrush(Qt::white); painter.drawRoundedRect(rect(), 8, 8); painter.end(); } }; class BaseWidget : public QWidget { public: }; static Button* create_label(const QString& content) { auto ret = new Button; ret->content.text = new Text(content); ret->content.layout.second_prefix = 4; ret->content.layout.second_suffix = 0; ret->content.layout.main_type = Layout::Prefix_Space; // ret->background.set_border(Qt::yellow); return ret; } static QLayout* create_input(const QString& content, const QString& unit) { auto ret = new QVBoxLayout; ret->setSpacing(0); ret->setMargin(0); auto label = create_label(content); ret->addWidget(label); auto core = new Input; core->unit = unit; core->focus_color = base; ret->addWidget(core); return ret; } static QLayout* create_check_box(const QString& content, const QVector& opt_list) { auto ret = new QVBoxLayout; ret->setSpacing(0); ret->setMargin(0); auto label = create_label(content); ret->addWidget(label); auto core = new ComboBox; for (auto& opt : opt_list) { core->addItem(opt); } ret->addWidget(core); return ret; } #endif