Chicken & egg issue in the TreeViewItem construction


#1

Hi,

I want to do spread a tree view item to the entire possible width like this:

int ContentItem::getItemWidth() const
{
    return getOwnerView()->getWidth() - getItemPosition(true)->getX();
}

However, while being added, the TreeViewItem::addSubItem calls getItemWidth(), which uses getItemPosition which is not set yet.
This lead to the first width being whatever the compiler decides to put in the initial width/itemWidth member.

I’m probably wrong computing the item width, but then I think a getOwnerBorderWidth() would be welcome.


#2

Well, to make it full-width you can just return -1 as the width, you know?


#3

Ok, so once again you’ve already thought of everything!
Thanks.


#4

Naturellement!