QtExamples/QtQStandardItemModelEx/ExQStandardItemModel.h
touwoyimuli 594e96fa50 feat: 添加、删除,预览,保存等功能实现
基本这里就是QStandardItemmodel的实际使用写完了;后面再写,就是在此基础上写代理部分功能
2019-09-28 00:02:57 +08:00

50 lines
1.7 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef EXQSTANDARDITEMMODEL_H
#define EXQSTANDARDITEMMODEL_H
#include <QMainWindow>
#include <QLabel>
#include <QStandardItemModel>
#include <QItemSelectionModel>
namespace Ui {
class ExQStandardItemModel;
}
class ExQStandardItemModel : public QMainWindow
{
Q_OBJECT
public:
explicit ExQStandardItemModel(QWidget *parent = nullptr);
~ExQStandardItemModel();
private:
void init(QStringList& list); //从list初始化数据模型
private slots:
void onCurrentChanged(const QModelIndex& current, const QModelIndex& previous); //当前单元格发生变化时
void on_actOpen_triggered(); //打开和导入文件并且在plainTextEdit里面显示
void on_actAppend_triggered(); //在表格的最后一行添加一行
void on_actSave_triggered(); //保存文件
void on_actInsert_triggered(); //在当前选中的一行,其前面插入一行
void on_actDelete_triggered(); //删除一行
void on_actExit_triggered(); //关闭退出
void on_actModelData_triggered(); //预览模型
void on_actAlignLeft_triggered(); //左对齐
void on_actAlignCenter_triggered(); //文本居中
void on_actAlingRight_triggered(); //文本右对齐
void on_actBold_triggered(bool checked);//文本加粗
private:
Ui::ExQStandardItemModel *ui;
QLabel *m_labCurrFile; //当前文件
QLabel *m_labCellPos; //当前单元格行列号
QLabel *m_labCellText; //当前单元格数据内容
QStandardItemModel *m_model; //数据模型
QItemSelectionModel *m_selectModet; //选择模型
};
#endif // EXQSTANDARDITEMMODEL_H