qtreeview vertical scrollbar
-
hello i have treeview
I want to put the scroll bar on the right.
MyStyleSheet is this
QTreeView{border : none; background-color : %4; outline :0; padding-left : 24px; padding-right : 24px;}If i give the view an padding Scroll bar follows
How can I make the scroll bar close to the right?
-
Hi,
On the right of what ?
QTreeView's scroll bars are by default on the right for the vertical one and on the bottom for the horizontal one. -
Hi
Just remove the right padding. Since it the thing that gives the gap anyway.The scrollbar is next to the internal viewport so padding the QTreeWidget itself will produce a empty space.
-
-
Hi
The QTreeView is a QAbstractScrollArea which actually handles the items with its viewport()
so you cant change it via QTreeView in stylesheet
as its not the one that draws the items, nor the one that has the scrollbars.From a fast test with
QAbstractScrollArea { border : none; background-color : red; outline :0; padding-left : 24px; padding-right : 0px; }
and in code
ui->treeView->viewport()->setStyleSheet("padding-right : 24px;" );I get this which you might be able to tweak to get the exact look. ( at least i hope so :)
Do note that the header view (name, size etc) don't care about the margin.
I did not look into this but I'm sure its also fixable if needed. -
Hi
I just placed a treeview on a form, right click and "Change Style sheet"
then use theQAbstractScrollArea { border : none; background-color : red; outline :0; padding-left : 24px; padding-right : 0px; }
and then i constructor for mainwindow i did
ui->treeView->viewport()->setStyleSheet("padding-right : 24px;" );
and also used a file model to have some data.