Results 1 to 3 of 3

Thread: Enabling scroll bars in disabled QTableView

  1. #1
    Join Date
    Sep 2008
    Posts
    13
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Enabling scroll bars in disabled QTableView

    Hi all!

    I have a QTableView that is disabled, but I'd like the user to still be able to see the data in the view using the scroll bars. The problem is that since the view is disabled the scrollbars are disabled as well, so no scrolling is possible.

    I have tried subclassing the view and installing an event filter in the scroll bar widgets so they can ignore the enabled change event, but with no success.

    Qt Code:
    1. myTableView::myTableView(QWidget *parent)
    2. : QTableView(parent)
    3. {
    4. this->horizontalScrollBar()->installEventFilter(this);
    5. this->verticalScrollBar()->installEventFilter(this);
    6. }
    7.  
    8. bool myTableView::eventFilter(QObject *o, QEvent *e)
    9. {
    10. if(e->type()==QEvent::EnabledChange)
    11. return true;
    12. else return false;
    13. }
    To copy to clipboard, switch view to plain text mode 

    Is there a way to keep the scroll bars enabled while the QTableView is disabled?

    Thanks a lot!

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Enabling scroll bars in disabled QTableView

    A quick work around is you can make table view non-editable and non-selectable and non-focusable. Then it will look like disabled.
    Call these functions:
    Qt Code:
    1. tableView->setSelectionMode(QAbstractItemView::NoSelection);
    2. tableView->setFocusPolicy( Qt::NoFocus);
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to yogeshgokul for this useful post:

    Koas (9th October 2009)

  4. #3
    Join Date
    Sep 2008
    Posts
    13
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Enabling scroll bars in disabled QTableView

    Thanks yogeshgokul, it works fine!!

Similar Threads

  1. scroll bars are not appearing
    By Cruz in forum Qt Programming
    Replies: 4
    Last Post: 10th September 2010, 17:26
  2. Replies: 1
    Last Post: 11th June 2009, 05:49
  3. QTableView and auto scroll
    By ranna in forum Qt Programming
    Replies: 0
    Last Post: 23rd March 2009, 13:02
  4. Adding scroll bars to a main window
    By dougab in forum Newbie
    Replies: 9
    Last Post: 25th December 2007, 20:27
  5. QScrollArea's Scroll Bars
    By ToddAtWSU in forum Qt Programming
    Replies: 5
    Last Post: 19th September 2006, 13:27

Tags for this Thread

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.