PDA

View Full Version : QTableView : ScrollBar ?



titoo
14th February 2007, 16:40
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 ?

titoo
14th February 2007, 17:00
lol, main window was big enough to show the table, but not enough to show the scrolling bar as well :rolleyes:

aamer4yu
15th February 2007, 05:14
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..

jpn
15th February 2007, 08:42
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():

QScrollBar * poScrollBar = verticalScrollBar(); // <---
:)

aamer4yu
15th February 2007, 08:55
Thanks for pointing my mistake...
but do u need to explicitly set a scrollbar for QTableView ???

jpn
15th February 2007, 09:15
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.

titoo
15th February 2007, 09:47
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 :eek:

jpn
15th February 2007, 09:52
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 :eek:
Sorry if I misunderstood you, but are you resizing the table by hand? That's what layouts (http://doc.trolltech.com/4.2/layout.html) are for.. ;)