From 72135d010cd96e0eb58bad7764a8816e75858297 Mon Sep 17 00:00:00 2001 From: touwoyimuli Date: Fri, 13 Sep 2019 18:39:53 +0800 Subject: [PATCH] feat: QTableWidget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 只是调整改项目代码的注释和风格样式,没有功能性的变化或者修复 --- QtQTableWidgetEx/ExQTableWidget.cpp | 1 + QtQTableWidgetEx/ExQTableWidget.h | 59 +++++++++++------------------ 2 files changed, 23 insertions(+), 37 deletions(-) diff --git a/QtQTableWidgetEx/ExQTableWidget.cpp b/QtQTableWidgetEx/ExQTableWidget.cpp index 5cd4cde..804f81f 100644 --- a/QtQTableWidgetEx/ExQTableWidget.cpp +++ b/QtQTableWidgetEx/ExQTableWidget.cpp @@ -28,6 +28,7 @@ ExQTableWidget::~ExQTableWidget() delete ui; } +//为某一行创建items void ExQTableWidget::createItemsARow(int row, QString name, QString sex, QDate birth, QString nation, int score, bool isAnime) { QTableWidgetItem* item = nullptr; diff --git a/QtQTableWidgetEx/ExQTableWidget.h b/QtQTableWidgetEx/ExQTableWidget.h index 3575367..595121d 100644 --- a/QtQTableWidgetEx/ExQTableWidget.h +++ b/QtQTableWidgetEx/ExQTableWidget.h @@ -15,12 +15,12 @@ class ExQTableWidget : public QMainWindow private: enum cellType { //自定义表格单元格TYPE的类型,创建item时使用 - ctName, - ctSex, - ctBirth, - ctNation, - ctScore, - ctLikeAnime + ctName, //姓名 + ctSex, //性别 + ctBirth, //出生日期 + ctNation, //籍贯 + ctScore, //分数 + ctLikeAnime //是否喜欢二次元 }; enum fieldColNum { //自定义各个表段在表格中的列号 @@ -39,37 +39,22 @@ public: void createItemsARow(int row, QString name, QString sex, QDate birth, QString nation, int score, bool isAnime); //为某一行创建items private slots: - void on_btnSetHeader_clicked(); - - void on_btnInitTable_clicked(); - - void on_btnSetRow_clicked(); - - void on_btnInsertRow_clicked(); - - void on_btnAddRow_clicked(); - - void on_btnDelRow_clicked(); - - void on_btnAutoHeight_clicked(); - - void on_btnAutoWidth_clicked(); - - void on_btnReadToEdit_clicked(); - - void on_chkBoxHeadEdit_clicked(bool checked); - - void on_chkBoxRowColor_clicked(bool checked); - - void on_chkBoxHeadRow_clicked(bool checked); - - void on_chkBoxHeadCol_clicked(bool checked); - - void on_radioBtnSelectItem_clicked(); - - void on_radioBtnSelectRow_clicked(); - - void on_tableWidget_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn); + void on_btnSetHeader_clicked(); //设置表头 + void on_btnInitTable_clicked(); //初始化数据表 + void on_btnSetRow_clicked(); //设置表格的行数 + void on_btnInsertRow_clicked(); //插入行 + void on_btnAddRow_clicked(); //在最后一行添加一行 + void on_btnDelRow_clicked(); //删除当前行 + void on_btnAutoHeight_clicked(); //自动设置行高 + void on_btnAutoWidth_clicked(); //自动设置列高 + void on_btnReadToEdit_clicked(); //读取表格内容到文本 + void on_chkBoxHeadEdit_clicked(bool checked); //表格可编辑模式 + void on_chkBoxRowColor_clicked(bool checked); //间隔行底色 + void on_chkBoxHeadRow_clicked(bool checked); //显示行表头 + void on_chkBoxHeadCol_clicked(bool checked); //显示列表头 + void on_radioBtnSelectItem_clicked(); //单元格选择 + void on_radioBtnSelectRow_clicked(); //行选择 + void on_tableWidget_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn); //获取当前item和前一个(点击)item的行列号 private: Ui::ExQTableWidget *ui;