×
Namespaces

Variants
Actions
Revision as of 11:03, 12 September 2009 by nayan_trivedi (Talk | contribs)

How to use QLCDNumber in Qt

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Emulator (5th edition)
Compatibility
Platform(s): S60 3rd Edition, S60 5th Edition
Symbian
Article
Keywords: QLCDNumber,QSpinBox
Created: (03 Jan 2008)
Last edited: nayan_trivedi (12 Sep 2009)
{{{width}}}

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

241 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.

×