Namespaces
Variants
Actions
(Difference between revisions)

Archived:Creating a Digital Clock QWidget

Jump to: navigation, search
(New page: Category:Qt for S60Category:Code Examples __NOTOC__ __NOEDITSECTION__ {{CodeSnippet |id=... |platform=S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition |devices= Emulator ...)
 
m (remove reference to qts60 sdk temple)
Line 19: Line 19:
 
==Preconditions==
 
==Preconditions==
  
* Install Qt for S60 Temple release from here: [http://pepper.troll.no/s60prereleases/ Qt for S60 "Temple" pre-release]
+
* Install latest Qt for S60 see [http://wiki.forum.nokia.com/index.php/Qt_for_S60_-_Installation_packages Qt for S60 - Installation packages]
 
* Check this link for installation guide: [http://pepper.troll.no/s60prereleases/doc/install-s60.html How to install the package].
 
* Check this link for installation guide: [http://pepper.troll.no/s60prereleases/doc/install-s60.html How to install the package].
 
* Go through this article: [[Getting started with Qt for S60]]
 
* Go through this article: [[Getting started with Qt for S60]]
 
  
 
== Source File ==
 
== Source File ==

Revision as of 13:44, 29 June 2009


Article Metadata

Tested with
Devices(s): Emulator

Compatibility
Platform(s): S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition

Article
Keywords: QLCDNumber,QTimer,QString
Created: (17 Feb 2009)
Last edited: jimgilmour1 (29 Jun 2009)


Overview

This code snippet demonstrates how to create a simple digital clock widget in Qt for S60.

Preconditions

Source File

#include <QtGui>
 
#include "digitalclock.h"
 
 
DigitalClock::DigitalClock(QWidget *parent)
: QLCDNumber(parent)
{
setSegmentStyle(Filled);
setNumDigits(8);
setStyleSheet("* { background-color:rgb(199,147,88);color:rgb(255,255,255); padding: 7px}}");
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(displayTime()));
timer->start(1000);
 
displayTime();
 
setWindowTitle(tr("Digital Clock"));
resize(300, 120);
}
 
 
 
void DigitalClock::displayTime()
 
{
QTime time = QTime::currentTime();
QString text = time.toString("hh:mm:ss");
if ((time.second() % 2) == 0)
{text[2] = ' ';
text[5] = ' ';
}
display(text);
}

Header File

#ifndef DIGITALCLOCK_H
#define DIGITALCLOCK_H
 
#include <QLCDNumber>
 
 
class DigitalClock : public QLCDNumber
{
Q_OBJECT
 
public:
DigitalClock(QWidget *parent = 0);
 
private slots:
void displayTime();
};
 
 
#endif

Screenshot

Digitalclocklarge.jpg

329 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved