(地基工)使用QTableView经验

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,  0 new  QTableWidgetItem(QString( " Group " )));
                tableBTRelations
-> setItem(row,  1 new  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,  0 new  QTableWidgetItem(QString( " ID " )));
                tableBTRelations
-> setItem(row,  1 new  QTableWidgetItem(QString(AppEditorUtils::O2QString( * iter))));
            }


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

你可能感兴趣的:((地基工)使用QTableView经验)