mytableview.h

来自「Qt开发的GRE背单词软件」· C头文件 代码 · 共 47 行

H
47
字号
/*
 *	TableView that can remember section sizes
 *  This is a simplified version, no popup menu, can't hide section...
 */

#ifndef MYTABLEVIEW_H
#define MYTABLEVIEW_H

#include <QTableView>
#include <map>

class QCloseEvent;

class MyTableView : public QTableView
{
	Q_OBJECT

	typedef std::map<int, float> Map;

public:
	MyTableView(QWidget* parent = 0);
	~MyTableView();

	void setTableName(const QString& table);
	void setSectionSize(int section, int size);
	void saveSectionSizes();

protected:
	virtual void resizeEvent    (QResizeEvent* event);
	virtual void mousePressEvent(QMouseEvent*  event);
	void loadSectionSizes();
	void resizeSections(Map& map);

protected slots:
	void slotResizeSections();
	void slotSetSectionSizes(int section, int oldSize, int newSize);

signals:
	void midClicked();

protected:
	Map sizes;
	QString tableName;
};

#endif // MYTABLEVIEW_H

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?