×
Namespaces

Variants
Actions

Archived:How to use a QDial

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.

This code snippet demonstrates how to use the QDial widget.

Article Metadata
Tested with
Devices(s): Symbian emulator
Compatibility
Platform(s): Qt
Symbian
Platform Security
Signing Required: Self-Signed
Capabilities: None
Article
Keywords: QDial,QSpinBox
Created: james1980 (25 Jan 2009)
Last edited: hamishwillee (11 Oct 2012)

Contents

Overview

The QDial class provides a rounded range control (like a speedometer or potentiometer). It is very similar to a slider available in Qt. Most of the signals and slots are similar to the QSlider.

QDial *dial = new QDial;

Various functions

  • This property holds whether the notches are shown.
dial->setNotchesVisible(1);
Dialwithnotch.png
  • To enable the wrapping if it is false then some space is inserted at the bottom of the dial to separate the ends of the range of valid values.
dial->setWrapping(1);
Dialwrapping.JPG
  • setNotchTraget(double target),this


Source File

#include "dial.h"
#include <QDial>
#include <QSpinBox>
#include <QVBoxLayout>
#include <QLabel>
dial::dial(QWidget *parent)
: QWidget(parent)
{
QVBoxLayout *layout = new QVBoxLayout(this);
QDial *dial = new QDial(this);
QSpinBox * spin = new QSpinBox(this);
QLabel *label=new QLabel("Change the Value",this);
spin->setMaximum(110);
spin->setMinimum(0);
bool visible=1;
connect(spin,SIGNAL(valueChanged(int)),dial,SLOT(setValue(int)));// Changing the value of spinbox will change the position of dial
connect(dial,SIGNAL(valueChanged(int)),spin,SLOT(setValue(int)));//Changing the position of dial will change the value of the spinbox
dial->setNotchesVisible(visible);// Display notches around the dial
layout->addWidget(label);
layout->addWidget(spin);
layout->addWidget(dial);
setStyleSheet("* { background-color:rgb(199,147,88); padding: 7px}}");
setLayout(layout);
}
 
dial::~dial()
{
// No need to delete any object that got a parent that is properly deleted.
}

Header File

#ifndef DIAL_H
#define DIAL_H
 
#include <QtGui/QWidget>
#include "ui_dial.h"
 
class dial : public QWidget
{
Q_OBJECT
 
public:
dial(QWidget *parent = 0);
~dial();
 
private:
Ui::dialClass ui;
};
 
#endif // DIAL_H

Screenshot

Dial.png

Dial1.png

This page was last modified on 11 October 2012, at 04:14.
126 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.

×