Project

General

Profile

layoutChanged not working in TreeView, if the first column is fixed

Added by Jockel Meierthiele about 6 years ago

Hi,

I have some code like this:

class MyTableModel: public Wt::WAbstractTableModel
{
  void sort(int column, Wt::SortOrder order)
  {
    layoutAboutToBeChanged().emit();
    ...
    layoutChanged().emit();
  }
}

And a container-widget with:

MyContainer::MyContainer(Wt::WContainerWidget* parent) :
        Wt::WContainerWidget(parent)
{
    auto* model = new MyTableModel;
    auto* view = new Wt::WTreeView;
    view->setModel(model);
    view->setRowHeaderCount(1);
    view->setColumnWidth(0, 100);

    auto* layout = new Wt::WVBoxLayout();
    layout->addWidget(view);

    setLayout(layout);
}

The treeview must be large enough to have horizontal scrollbars and it is important, that the first column is fixed.

If you scroll the treeview and than click on a header-cell to sort, the content of the tree-view will scroll to the left

(instead of keeping its position), but the header and the scrollbars keep their position.

I think this is a bug, but I think this layout is not very unusual, so someone has perhaps a work-around?

Thank you.