QTreeWidget设置item的内容
本帖最后由 fengwanfengwan 于 2012-05-04 15:07:58 编辑
QTreeWidget* treewidget = new QTreeWidget(this);
QTreeWidgetItem* item1 = new QTreeWidgetItem(treewidget);
QTreeWidgetItem* item2 = new QTreeWidgetItem(treewidget);
QString dst("Destination address");
QString src("Source address");
dst.append("=11-22-33-44-55-66");
src.append("=77-88-99-aa-bb-cc");
padString( dst, 25 );
padString( src, 25 );
item1->setText( 0, dst );
item2->setText( 0, src );
void padString( QString& str, int strlen )
{
int len = str.size();
QChar fillChar( ' ' );
for( int i= 0; i < ( strlen - len ); i++ )
{
str.append( fillChar );
}
}