Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

How to use QScrollBar in Qt

From Wiki
Jump to: navigation, search
Article Metadata
Compatibility
Platform(s):
Symbian
Article
Created: mind_freak (10 Mar 2009)
Last edited: hamishwillee (11 Oct 2012)

Contents

Overview

Scroll bar is a control that enables the user to access parts of a document that is larger than the widget used to display it. It provides a visual indication of the user's current position within the document and the amount of the document that is visible. Scroll bars are usually equipped with other controls that enable more accurate navigation. Qt displays scroll bars in a way that is appropriate for each platform.[1]

Scroll1viral.JPG

Various Function

  • To set the orientation of scroll Bar,by default it is horizontal.
QScrollBar *scroll=new QScrollBar();
scroll->setOrientation(Qt::Horizontal/Qt::Vertical);

ScrollBar.JPG

  • To resize the scroll Bar.
scroll->resize(60,40);

Scrollresize.JPG

  • This property holds the page step.
scroll->setPageStep(200);

Scrollsteping.JPG

  • To set the minimum/maximum range of scrollbar.
scroll->setMinimum(0);
scroll->setMaximum(100);

For more details visit: http://doc.trolltech.com/3.3/qscrollbar.html

Source Code

#include <QtGui>
#include <QApplication>
#include<QScrollBar>
#include<QWidget>
#include<QVBoxLayout>
#include<QProgressBar>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *window=new QWidget();
QVBoxLayout *layout =new QVBoxLayout();
QScrollBar *scroll=new QScrollBar();
scroll->setOrientation(Qt::Vertical);
scroll->setMinimum(0);
scroll->setMaximum(100);
scroll->setTracking(0);
scroll->resize(60,40);
scroll->setPageStep(200);
QProgressBar *bar=new QProgressBar();
bar->setMinimum(0);
bar->setMaximum(100);
bar->setTextVisible(1);
layout->addWidget(scroll);
layout->addWidget(bar);
QObject::connect(scroll,SIGNAL(valueChanged(int)),bar,SLOT(setValue(int)));
window->setLayout(layout);
window->show();
return a.exec();
}


Screenshot

For more details visit: http://doc.trolltech.com/3.3/qscrollbar.html

Scrollsteping.JPG

This page was last modified on 11 October 2012, at 01:17.
185 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×