×
Namespaces

Variants
Actions

How to use QLCDNumber in Qt

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Code Example
Source file: Media:Lcdnumber.zip
Tested with
Devices(s): Emulator (S60 5th edition)
Compatibility
Platform(s): Qt
Symbian
Article
Keywords: QLCDNumber,QSpinBox
Created: james1980 (03 Jan 2008)
Last edited: hamishwillee (11 Oct 2012)

Contents

Introduction

This article shows the use of LCD number to display some number. For example it can be use to display a score while designing a game.

Various Functions

  • This line create a object of the LCDNumber.
QLCDNumber* number = new QLCDNumber(this);

Lcd.JPG

  • To specify the segment display style of the LCD number. Qt support the three different filled style i.e. Filled,Outline and Flat.
number->setSegmentStyle(QLCDNumber::Filled);

Lcdsegmentstyle.JPG

  • To specify the number of LCD digits that would be display.This function specify the mode of the LCD. Various supported modes are Hex,Dec,Bin and Oct.
number->setMode(QLCDNumber::Hex);

Lcdhex.JPG

Related Link

  • Check this digital clock example that shows the use of the QLCDNumber.


Source Code

Header file

#ifndef LCDNUMBER_H
#define LCDNUMBER_H
 
#include <QWidget>
#include <QLCDNumber>
#include <QSpinBox>
#include <QVBoxLayout>
 
class lcdnumber : public QWidget
{
Q_OBJECT
 
public:
lcdnumber(QWidget *parent = 0);
~lcdnumber();
private:
QVBoxLayout* layout;
QLCDNumber* number;
QSpinBox* spin;
 
};
 
#endif // LCDNUMBER_H

Source file

#include "lcdnumber.h"
 
lcdnumber::lcdnumber(QWidget *parent)
: QWidget(parent)
{
 
setWindowTitle(("LCD Number"));
layout = new QVBoxLayout(this);
number = new QLCDNumber(this);
spin = new QSpinBox(this);
spin->setMaximum(9);
spin->setMinimum(0);
 
connect(spin, SIGNAL(valueChanged(int)), number, SLOT(display(int)));
layout->addWidget(spin,Qt::AlignCenter);
 
layout->addWidget(number,Qt::AlignCenter);
showMaximized();
}
 
lcdnumber::~lcdnumber()
{
 
}

Screenshot

Lcd.JPG

This page was last modified on 11 October 2012, at 01:17.
254 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.

×