Files
GUI/src/SelectFormWidget.cpp

90 lines
3.5 KiB
C++
Raw Normal View History

2021-10-09 16:38:34 +08:00
//
// Created by Krad on 2021/10/8.
//
#include "ui_tabformwidget.h"
#include "SelectFormWidget.h"
#include <QHBoxLayout>
#include <QToolButton>
#include <QTableWidget>
#include <QHeaderView>
#include "editpatientform.h"
#include "guimacros.h"
2021-10-11 09:22:31 +08:00
#define ADD_CENTER_ITEM(row,col,text)\
item = new QTableWidgetItem(text);\
item->setTextAlignment(Qt::AlignmentFlag::AlignCenter);\
table->setItem(row,col,item);
2021-10-09 16:38:34 +08:00
SelectFormWidget::SelectFormWidget(QWidget *parent) :
TabFormWidget(parent)
{
const char* style="QHeaderView::section{background-color:#595959;"
" min-height:50px;max-height:50px;"
"font-weight:Bold; font-size:16px; border:1px solid #323232;}"
"QHeaderView::section:horizontal{border-bottom: 1px solid rgb(0,170,255);}"
"QHeaderView::section:vertical{min-height:36px;max-height:36px;}"
"QWidget#edit_patient{min-width:300px;max-width:300px;}"
// "QTableWidget{border:1px solid #323232}"
"QTableWidget{border:none}"
"QTableView{alternate-background-color: #595959;}"
;
this->setStyleSheet(this->styleSheet().append(style));
QHBoxLayout* layout =new QHBoxLayout();
ui->commandWidget->setLayout(layout);
ADD_TOOL_BTN(Account,":/icons/account.png");
ADD_TOOL_BTN(Setting,":/icons/setting.png");
layout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding));
QWidget* spacerLine= new QWidget(this);
spacerLine->setFixedWidth(2);
spacerLine->setObjectName("verSpaceLine");
layout->addWidget(spacerLine);
ADD_TOOL_BTN(Add,":/icons/add.png");
ADD_TOOL_BTN(Detail,":/icons/details.png");
ADD_TOOL_BTN(Delete,":/icons/close_circle.png");
ADD_TOOL_BTN(Select,":/icons/selected.png");
QHBoxLayout* contentLayout =new QHBoxLayout();
this->ui->contentWidget->setLayout(contentLayout);
QStringList header;
header<<"ID"<<"Name"<<"Sex"<<"DOB"<<"Status"<<"Comment";
QTableWidget* table= new QTableWidget(this);
table->setAlternatingRowColors(true);
table->setSelectionMode(QAbstractItemView::SingleSelection);
table->setSelectionBehavior(QAbstractItemView::SelectRows);
table->setColumnCount(6);
table->verticalHeader()->setDefaultSectionSize(38);
table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
table->setHorizontalHeaderLabels(header);
table->setRowCount(3);
2021-10-11 09:22:31 +08:00
QTableWidgetItem* item ;
ADD_CENTER_ITEM(0,0,"Pat010012313");
ADD_CENTER_ITEM(0,1,"XXX");
ADD_CENTER_ITEM(0,2,"Female");
ADD_CENTER_ITEM(0,3,"1978/09/06");
ADD_CENTER_ITEM(0,4,"Added");
ADD_CENTER_ITEM(0,5,"");
ADD_CENTER_ITEM(1,0,"Pat0222222");
ADD_CENTER_ITEM(1,1,"XXX2");
ADD_CENTER_ITEM(1,2,"Female");
ADD_CENTER_ITEM(1,3,"1993/08/16");
ADD_CENTER_ITEM(1,4,"Scanned");
ADD_CENTER_ITEM(1,5,"");
ADD_CENTER_ITEM(2,0,"Pat3");
ADD_CENTER_ITEM(2,1,"XX3");
ADD_CENTER_ITEM(2,2,"Female");
ADD_CENTER_ITEM(2,3,"1999/08/16");
ADD_CENTER_ITEM(2,4,"Scanned");
ADD_CENTER_ITEM(2,5,"");
2021-10-09 16:38:34 +08:00
contentLayout->addWidget(table);
QWidget* spacerLine2= new QWidget(this);
spacerLine2->setFixedWidth(2);
spacerLine2->setObjectName("verSpaceLine");
contentLayout->addWidget(spacerLine2);
EditPatientForm* edit_patient= new EditPatientForm(this);
edit_patient->setObjectName("edit_patient");
contentLayout->addWidget(edit_patient);
}
SelectFormWidget::~SelectFormWidget()
{
}