Results 1 to 6 of 6

Thread: Scrollbar on the left

  1. #1
    Join Date
    May 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Scrollbar on the left

    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.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Scrollbar on the left

    Qt Code:
    1. anyAbstractScrollArea->setLayoutDirection(Qt::RightToLeft);
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. #3
    Join Date
    May 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Scrollbar on the left

    Quote Originally Posted by jpn View Post
    Qt Code:
    1. anyAbstractScrollArea->setLayoutDirection(Qt::RightToLeft);
    To copy to clipboard, switch view to plain text mode 
    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.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Scrollbar on the left

    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.
    J-P Nurmi

  5. The following user says thank you to jpn for this useful post:

    tituslup (14th September 2009)

  6. #5
    Join Date
    May 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Scrollbar on the left

    It looks like this is the way to go. Thank you for your time.

  7. #6
    Join Date
    Apr 2008
    Location
    Cluj-Napoca, Romania
    Posts
    10
    Thanks
    5
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Smile Re: Scrollbar on the left

    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:

    Qt Code:
    1. QTableView* reportTableView = new QTableView(this);
    2. reportTableView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    3.  
    4. QScrollBar* scrollBar = reportTableView->verticalScrollBar();
    5.  
    6. // Add widgets to H layout.
    7. layout->addWidget(scrollBar);
    8. layout->addWidget(reportTableView );
    To copy to clipboard, switch view to plain text mode 

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

Similar Threads

  1. QScrollarea events transferring to scrollbar
    By babu198649 in forum Qt Programming
    Replies: 15
    Last Post: 6th September 2013, 23:33
  2. scrollbar on left side of qtextedit
    By piotrek in forum Qt Programming
    Replies: 1
    Last Post: 15th February 2008, 22:07
  3. Treeview scrollbar not updating when inserting rows
    By Khal Drogo in forum Qt Programming
    Replies: 11
    Last Post: 29th November 2007, 14:13
  4. GraphicsView/GraphicsScene: scrollbar policy Qt::ScrollBarAsNeeded
    By Pieter from Belgium in forum Qt Programming
    Replies: 4
    Last Post: 21st March 2007, 14:15
  5. about scrollbar style
    By qtopiahooo in forum Qt Programming
    Replies: 1
    Last Post: 25th January 2007, 14:34

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.