PDA

View Full Version : Scrollbar on the left



torn
28th August 2009, 12:13
How can I move the scrollbar of a QTreeView/QListView to the left edge of the widget? I want the scrollbar to be on the left side for a specific widget in my app.

jpn
28th August 2009, 12:21
anyAbstractScrollArea->setLayoutDirection(Qt::RightToLeft);

torn
28th August 2009, 12:37
anyAbstractScrollArea->setLayoutDirection(Qt::RightToLeft);

The problem with this solution is that it moves icons on the right side and aligns text to right. I'd like to change scrollbar position but keep the content intact.

jpn
28th August 2009, 12:47
But that's quite weird to have a scroll bar on the left in a LTR layout, isn't it? :) You might be better off with a custom scroll bar, then. You can hide the scroll bar provided by the abstract scroll area by adjusting the scroll bar policy. Use layouts to place a scroll bar on the left side of the scroll area and connect signals from/to the hidden scroll bar to make the custom scroll bar functional. Notice that you have to sync both range and value.

torn
28th August 2009, 14:53
It looks like this is the way to go. Thank you for your time.

tituslup
14th September 2009, 09:22
I also needed to place a scroll bar on the left side of a tableView, and based on the layout advice from jpn, i did is the fallowing:




QTableView* reportTableView = new QTableView(this);
reportTableView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff) ;

QScrollBar* scrollBar = reportTableView->verticalScrollBar();

// Add widgets to H layout.
layout->addWidget(scrollBar);
layout->addWidget(reportTableView );



This way you use the existing scrollBar, but place it on the left.
Hope this works right.