aboutsummaryrefslogtreecommitdiff
path: root/works/life/cpp-practicum/main.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-12-30 17:23:15 +0800
committercrupest <crupest@outlook.com>2020-12-30 17:23:15 +0800
commitd0b6d6377de44484568af2ef3a3bbd4da7cdfb4b (patch)
treeee87702ec50a5c5a26ee8fb446bd4995082bd792 /works/life/cpp-practicum/main.cpp
parent1e148e88abe8aca881590f4b9d992a2f03587ed7 (diff)
downloadcrupest-d0b6d6377de44484568af2ef3a3bbd4da7cdfb4b.tar.gz
crupest-d0b6d6377de44484568af2ef3a3bbd4da7cdfb4b.tar.bz2
crupest-d0b6d6377de44484568af2ef3a3bbd4da7cdfb4b.zip
import(life): ...
Diffstat (limited to 'works/life/cpp-practicum/main.cpp')
-rw-r--r--works/life/cpp-practicum/main.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/works/life/cpp-practicum/main.cpp b/works/life/cpp-practicum/main.cpp
index 14847cc..b7e5db5 100644
--- a/works/life/cpp-practicum/main.cpp
+++ b/works/life/cpp-practicum/main.cpp
@@ -1,7 +1,9 @@
-#include "qboxlayout.h"
-#include "qtableview.h"
+#include "Record.hpp"
+#include "qabstractitemview.h"
+
#include <QApplication>
#include <QHBoxLayout>
+#include <QHeaderView>
#include <QMainWindow>
#include <QPushButton>
#include <QTableView>
@@ -20,19 +22,35 @@ int main(int argc, char *argv[]) {
QPushButton import_button(QStringLiteral("导入"));
QPushButton export_button(QStringLiteral("导出"));
+ QPushButton add_book_button(QStringLiteral("添加书"));
+
top_bar.addWidget(&import_button);
top_bar.addWidget(&export_button);
top_bar.addStretch(1);
+ top_bar.addWidget(&add_book_button);
QHBoxLayout center_area;
window_layout.addLayout(&center_area);
QTableView book_view;
+ book_view.verticalHeader()->hide();
+ book_view.setSelectionBehavior(QAbstractItemView::SelectRows);
+ book_view.setEditTriggers(QAbstractItemView::DoubleClicked);
+ book_view.setSelectionMode(QAbstractItemView::SingleSelection);
QTableView vendor_view;
center_area.addWidget(&book_view);
center_area.addWidget(&vendor_view);
+ Record record;
+ BookModel book_model(&record);
+
+ book_view.setModel(&book_model);
+
+ QObject::connect(&add_book_button, &QPushButton::clicked, [&book_model]() {
+ book_model.insertRow(book_model.rowCount());
+ });
+
window.show();
return application.exec();