QListView实现表格驱动

来源:百度文库 编辑:神马文学网 时间:2024/04/28 15:56:48
1.表格内容:// 表格头结构
typedef struct{
 int width;    // 宽度
 char* text;    // 描述
} GRID_HEAD; static GRID_HEAD Header[] = {
 { 25, "" },
 { 35, "序号" },
 { 240, "操作步骤" },
 { 35, "类型" },
}; 2.表格驱动实现: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);