×
Namespaces

Variants
Actions

Archived:How to use QDoubleSpinBox

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): Qt Creator IDE & S60 Emulator
Compatibility
Platform(s): S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition
Symbian
Article
Keywords: QDoubleSpinBox
Created: mind_freak (14 Mar 2009)
Last edited: hamishwillee (11 Oct 2012)

Contents

Introduction

This article shows how to use QDoubleSpinBox, a spin box that takes doubles. The widget allows the user to choose a value by clicking the up and down buttons or by pressing Up or Down on the keyboard to increase or decrease the value currently displayed. The user can also type the value in manually.

Note.pngNote: QDoubleSpinBox will round numbers so they can be displayed with the current precision. In a QDoubleSpinBox with decimals set to 2, calling setValue(2.555) will cause value() to return 2.5.


New Feature

  • Most spin boxes are directional, but QSpinBox can also operate as a circular spin box.
  • This Spin Box support floating point value.

Preconditions

  • Download and install the [[Qt SDK]

Various Function

  • To make this spin Box Circular.
doubleSpin->setWrapping(1);
  • This property holds the step value.
doubleSpin->setSingleStep(0.1);
  • This property holds the suffix of the spin box.
doubleSpin->setSuffix(" km");

Source Code

#include <QtGui/QApplication>
#include "doublespindialog.h"
#include<QWidget>
#include<QHBoxLayout>
#include<QDoubleSpinBox>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *win=new QWidget();
QHBoxLayout *lay=new QHBoxLayout();
QDoubleSpinBox *doubleSpin=new QDoubleSpinBox();
doubleSpin->setMinimum(0.0);
doubleSpin->setMaximum(100.0);
doubleSpin->setWrapping(1);
doubleSpin->setSingleStep(0.1);
lay->addWidget(doubleSpin);
win->setLayout(lay);
win->showMaximized();
win->setStyleSheet("* { background-color:rgb(150,147,88); padding: 7px ; color:rgb(255,255,255)}");
return a.exec();
}

Screenshot

Douspin.jpg

This page was last modified on 11 October 2012, at 04:14.
84 page views in the last 30 days.
×