
Originally Posted by
allensr
if I just hardcode 0 in the call I get the correct text string.
If you want the text from column 0, there's no other way than hardcode that 0 somewhere.
You can subclass QTreeWidgetItem and add a method that returns the text you want:
QString MyTreeWidgetItem
::name() const {
return text( 0 );
}
...
MyTreeWidgetItem *item = dynamic_cast< MyTreeWidgetItem * >( widgetItem );
if( item ) {
parentName = item->name();
}
QString MyTreeWidgetItem::name() const
{
return text( 0 );
}
...
MyTreeWidgetItem *item = dynamic_cast< MyTreeWidgetItem * >( widgetItem );
if( item ) {
parentName = item->name();
}
To copy to clipboard, switch view to plain text mode
Alternatively you can define an enum and name those columns:
enum SomeItemColumn {
Name = 0,
SomethingElse = 1,
AndSoOn = 2
};
...
parentName = item->text( Name );
enum SomeItemColumn {
Name = 0,
SomethingElse = 1,
AndSoOn = 2
};
...
parentName = item->text( Name );
To copy to clipboard, switch view to plain text mode
Bookmarks