×
Namespaces

Variants
Actions

Archived:How to use QSpinBox and QSlider

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Qt Quick should be used for all UI development on mobile devices. The approach described in this article (based on QWidget) is deprecated.

Article Metadata
Tested with
Devices(s): Emulator
Compatibility
Platform(s): S60 3rd Edition, S60 5th Edition
Symbian
Platform Security
Signing Required: Self-Signed
Capabilities: None
Article
Keywords: QSpinBox,QSlider
Created: kamaljaiswal (21 Dec 2008)
Last edited: hamishwillee (11 Oct 2012)

Contents

QSpinBox and the QSlider are rendered inside the QWidget ie QSpinBox and QSlider are compound controls.

QSpinBox *spinBox = new QSpinBox;
QSlider *slider = new QSlider(Qt::Horizontal);

Various Function For SpinBox

  • To set the minimum and maximun range of spin box.
spinBox->setMinimum(0);
spinBox->setMaximum(100);
  • This property is used to display spinBox prefix For example $50 .
spinBox->setPrefix("$");

ScreenShot

Untitled1.JPG

  • This property is used to display spinBox suffix ,Example 100Km.
spinBox->setSuffix(" Km");

Various Function For Slider

  • Used to fix the tick interval.
slider->setTickInterval ( 5 );
  • This property is generally used to tickmark the position of slider.
slider->setTickPosition(QSlider::TicksBothSides); 

ScreenShot

SpinBoxAndSlider.jpeg

Specifying the range.

spinBox->setRange(0, 130);
slider->setRange(0, 130);

Catching the event generated by the Slider and SpinBox.

QObject::connect(spinBox, SIGNAL(valueChanged(int)),
slider, SLOT(setValue(int)));
QObject::connect(slider, SIGNAL(valueChanged(int)),
spinBox, SLOT(setValue(int)));

Setting a default value

spinBox->setValue(35);

Alignment

QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(spinBox);
layout->addWidget(slider);
window->setLayout(layout);
This page was last modified on 11 October 2012, at 04:14.
150 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.

×