[Qt-interest] Horizontal scroll bar max value.

phil prentice philp.cheer at talktalk.net
Mon Apr 27 12:10:43 CEST 2009


Hi Everyone

  I am having problems trying to make a scroll bar work the way I want it to 
in a QListView(). I need to be able to scroll the existing data right out of 
the view i.e.

                               Display Area
                             _____________
                             |                      |
                             |                      |
<-------Items---------->|<....empty.....>|
                             |                      |
                             |                      |
                             -----------------------

I've tried various things, but failed. For example if I create a long file 
name say XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

and I run the following program I cant seem to change the maximum value or get 
the results that I need?

#include <QtGui>
int main(int argc, char *argv[])
{
  QApplication app(argc, argv);
  QSplitter *splitter = new QSplitter;
  QDirModel *model = new QDirModel;
  QListView *list = new QListView(splitter);
  list->setModel(model);
  list->setRootIndex(model->index(QDir::currentPath()));
  splitter->setWindowTitle("PLEASE HELP!!!");
  list->verticalScrollBar()->setMaximum(500); /* Tryed various things. */
  list->verticalScrollBar()->setPageStep(50);
  splitter->show();
  return app.exec();
}

I can play around with setMaximum() & setPageStep() to no avail???
I've tryed sub-classing QScrollBar but again no luck.  How can I achieve my 
requirement.

Thanks
Any comments very welcome

Phil




More information about the Qt-interest-old mailing list