Results 1 to 8 of 8

Thread: QTableView : ScrollBar ?

  1. #1
    Join Date
    Feb 2007
    Posts
    12

    Default QTableView : ScrollBar ?

    i try to show the vertical scrollbar of a QTableView, have tried all methods :

    setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
    setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn );

    QScrollBar * poScrollBar = verticalScrollBar();
    poScrollBar->setAutoFillBackground( true );
    poScrollBar->setHidden( false );
    poScrollBar->show();
    poScrollBar->setHidden( false );
    poScrollBar->setShown( true );
    poScrollBar->show();
    poScrollBar->showNormal();

    but still i can't see any scrollbar...
    what's the trick to display it ?

  2. #2
    Join Date
    Feb 2007
    Posts
    12

    Default Re: QTableView : ScrollBar ?

    lol, main window was big enough to show the table, but not enough to show the scrolling bar as well

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView : ScrollBar ?

    First thing... Dont you need to set the scrollbar somewhere ?? u have just created it without parent, but not adding it anywhere?? i am not sure, but i might be wrong


    Second, QTableView will automatically provide scrollbar...its derived from QAbstractScrollArea... so remove ur scrollbar code and check if scroll bars are added automatically or not..

  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: QTableView : ScrollBar ?

    Quote Originally Posted by aamer4yu View Post
    First thing... Dont you need to set the scrollbar somewhere ?? u have just created it without parent, but not adding it anywhere?? i am not sure, but i might be wrong

    Second, QTableView will automatically provide scrollbar...its derived from QAbstractScrollArea... so remove ur scrollbar code and check if scroll bars are added automatically or not..
    Well, actually he is using the built-in scroll bar, QAbstractScrollArea::verticalScrollBar():
    Qt Code:
    1. QScrollBar * poScrollBar = verticalScrollBar(); // <---
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  5. #5
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView : ScrollBar ?

    Thanks for pointing my mistake...
    but do u need to explicitly set a scrollbar for QTableView ???

  6. #6
    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: QTableView : ScrollBar ?

    Quote Originally Posted by aamer4yu View Post
    Thanks for pointing my mistake...
    but do u need to explicitly set a scrollbar for QTableView ???
    No, the scroll bars will appear "on their own" when required, according to applied policies and geometries.
    J-P Nurmi

  7. #7
    Join Date
    Feb 2007
    Posts
    12

    Default Re: QTableView : ScrollBar ?

    am sorted guys, behavior is correct this was only a problem of size of the parent widget, so i could see the tableview but not the scrollbar cuz the right border of the tableview was very closed from the main window right border and then the vertical scrollbar was truncated by autoresize of the tableview

  8. #8
    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: QTableView : ScrollBar ?

    Quote Originally Posted by titoo View Post
    am sorted guys, behavior is correct this was only a problem of size of the parent widget, so i could see the tableview but not the scrollbar cuz the right border of the tableview was very closed from the main window right border and then the vertical scrollbar was truncated by autoresize of the tableview
    Sorry if I misunderstood you, but are you resizing the table by hand? That's what layouts are for..
    J-P Nurmi

Similar Threads

  1. GraphicsView/GraphicsScene: scrollbar policy Qt::ScrollBarAsNeeded
    By Pieter from Belgium in forum Qt Programming
    Replies: 4
    Last Post: 21st March 2007, 13:15
  2. about scrollbar style
    By qtopiahooo in forum Qt Programming
    Replies: 1
    Last Post: 25th January 2007, 13:34
  3. QTableView paints too much
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2006, 18:42
  4. Multi-line messages in QTableView
    By Conel in forum Qt Programming
    Replies: 6
    Last Post: 13th April 2006, 13:49
  5. QTableView number of rows and scrollbar issue
    By jnk5y in forum Qt Programming
    Replies: 3
    Last Post: 1st March 2006, 06:55

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.