|
1.表格內(nèi)容:
// 表格頭結(jié)構(gòu)
typedef struct{ int width; // 寬度 char* text; // 描述 } GRID_HEAD; static GRID_HEAD Header[] = {
{ 25, "" }, { 35, "序號(hào)" }, { 240, "操作步驟" }, { 35, "類型" }, }; 2.表格驅(qū)動(dòng)實(shí)現(xiàn):
void CDlgImpl::InitListView(int cols, GRID_HEAD* header, QListView* pView)
{ pView->setSorting(-1); GRID_HEAD* pHeader = header; for (int col = 0; col < cols; col++) { pView->addColumn(tr(pHeader->text), pHeader->width); pHeader++; } } 3.使用:
// ListView初始化
InitListView(sizeof(Header) / sizeof(GRID_HEAD), Header, lstView); |
|
|