posts - 311, comments - 0, trackbacks - 0, articles - 0
  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

(地基工)使用QTableView经验

Posted on 2011-06-01 15:16 点点滴滴 阅读(761) 评论(0)  编辑 收藏 引用 所属分类: 02 编程语言
1.使用QTableView增加行
            tableBTRelations->setRowCount(0);
            BuffTemplate::BuffGroups
& pBuffGroups = pBuffRelationData->getBuffGroups();
            
for (BuffTemplate::BuffGroups::iterator iter = pBuffGroups.begin(); iter != pBuffGroups.end(); ++ iter)
            {
                
int row = tableBTRelations->rowCount();
                tableBTRelations
->insertRow(row);
                tableBTRelations
->setItem(row, 0new QTableWidgetItem(QString("Group")));
                tableBTRelations
->setItem(row, 1new QTableWidgetItem(QString(AppEditorUtils::O2QString(*iter))));
            }

            BuffTemplate::BuffTemplates
& pBuffTemplates = pBuffRelationData->getBuffTemplates();
            
for (BuffTemplate::BuffTemplates::iterator iter = pBuffTemplates.begin(); iter != pBuffTemplates.end(); ++ iter)
            {
                
int row = tableBTRelations->rowCount();
                tableBTRelations
->insertRow(row);
                tableBTRelations
->setItem(row, 0new QTableWidgetItem(QString("ID")));
                tableBTRelations
->setItem(row, 1new QTableWidgetItem(QString(AppEditorUtils::O2QString(*iter))));
            }


2.使用QTableView自适应内容
tableBTRelations->resizeColumnsToContents();