I've a problem with QTreeView horizontal scrollbar, it doesn't appear. I've set horizontal scrollbar policy to ScrollBarAsNeeded, but it doesn't appear if needed. Have tried to connect expanded and collapsed signals to a slot:
connect(this, SIGNAL(expanded(QModelIndex)), this, SLOT(update_scroll_area(QModelIndex)));
connect(this, SIGNAL(collapsed(QModelIndex)), this, SLOT(update_scroll_area(QModelIndex)));
To copy to clipboard, switch view to plain text mode
The slot consists of one line of code:
void update_scroll_area(const QModelIndex& i)
{
resizeColumnToContents(i.column());
}
void update_scroll_area(const QModelIndex& i)
{
resizeColumnToContents(i.column());
}
To copy to clipboard, switch view to plain text mode
This makes scrollbar working, but only when I'm expanding/collapsing the tree view items.
I need to have working horizontal scrollbar "every time", from starting the application till its end. How can it be organized?
Thank you.
UPD: Have tried this code, but didn't help:
header
()->setResizeMode
(QHeaderView::ResizeToContents);
header()->setStretchLastSection(false);
header()->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
header()->setResizeMode(QHeaderView::ResizeToContents);
header()->setStretchLastSection(false);
To copy to clipboard, switch view to plain text mode
Bookmarks