Originally Posted by
wysota
Reimplement the widget's sizeHint() method.
Thanks! I re-implement it with following:
QSize TreeView
::sizeHint() const {
int doubleFrame = 2 * frameWidth();
int w = header()->length() + doubleFrame;
int h = height() + doubleFrame;
}
QSize TreeView::sizeHint() const
{
int doubleFrame = 2 * frameWidth();
int w = header()->length() + doubleFrame;
int h = height() + doubleFrame;
return QSize(w, h);
}
To copy to clipboard, switch view to plain text mode
As well, I connect(treeView, SIGNAL(expanded(const QModelIndex&)), treeView, SLOT(needResize(const QModelIndex&)));
void TreeView::needResize(const QModelIndex& index)
{
resize(sizeHint());
updateGeometry();
}
void TreeView::needResize(const QModelIndex& index)
{
resize(sizeHint());
updateGeometry();
}
To copy to clipboard, switch view to plain text mode
And it works. Have I done it right?
Bookmarks