[Interest] QTreeView width with scroll bar
Alex Strickland
sscc at mweb.co.za
Thu Nov 8 08:39:54 CET 2012
On 2012/11/08 09:23 AM, Alex Strickland wrote:
> However, when the QTreeView gets long enough to automatically add a
> scroll bar - my calculations don't work and one of the check box columns
> is obscured by the scrollbar. How can I check if the scroll bar is
> activated and, if so, obtain it's width to factor into my calculation?
I should write the message and just not send it... :
class CrossTabTreeView : public QTreeView
{
public:
CrossTabTreeView(QWidget* parent = 0) : QTreeView(parent) {}
void resizeEvent(QResizeEvent* /*event - suppress unused warning*/)
{
if (model()->columnCount() == CrossTabView::ColumnCount) {
int scrollBarWidth = 0;
QScrollBar* scrollBar = verticalScrollBar();
if (scrollBar) {
if (scrollBar->isVisible())
scrollBarWidth = scrollBar->width();
}
resizeColumnToContents(CrossTabView::RowColumn);
resizeColumnToContents(CrossTabView::ColumnColumn);
setColumnWidth(CrossTabView::QuestionColumn,
width() - columnWidth(CrossTabView::RowColumn)
- columnWidth(CrossTabView::ColumnColumn) -
scrollBarWidth);
}
}
};
--
Regards
Alex
More information about the Interest
mailing list