You Are Here:

Community: Wiki

This page was last modified on 4 November 2009, at 08:37.

How to make customized Widget (Qt for Symbian)

From Forum Nokia Wiki

Reviewer Approved   


ID Creation date 30 December 2008
Platform S60 3rd Edition, S60 5th Edition Tested on devices Emulator
Category Qt for Symbian Subcategory Customized Widget


Keywords (APIs, classes, methods, functions): Customized Widget


Introduction

This example shows the procedure for making your own customized widget by using the widget available in the Qt for Symbian.

Create a new Qt project of type GUI widget. Follow the procedure given in this article for creating new project.

Now replace the three files named main.cpp, customwidget.h and customwidget.cpp with the code given below.

Main.cpp

#include <QApplication>
 
#include "customwidget.h"
 
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
CustomWidget w;
w.show();
return a.exec();
}


customwidget.h

#ifndef CUSTOMWIDGET_H
#define CUSTOMWIDGET_H
 
#include <QWidget>
 
class CustomWidget : public QWidget
{
Q_OBJECT
 
public:
CustomWidget(QWidget *parent = 0);
};
 
#endif // CUSTOMWIDGET_H


customwidget.cpp

#include <QPushButton>
#include <QVBoxLayout>
#include <QCoreApplication>
 
#include "customwidget.h"
 
CustomWidget::CustomWidget(QWidget *parent) :
QWidget(parent)
{
QVBoxLayout* layout = new QVBoxLayout(this);
 
// This button show the top level widget in a normal size
QPushButton* normalSizeButton = new QPushButton("Normal size");
QObject::connect(normalSizeButton, SIGNAL(clicked()), this, SLOT(showNormal()));
layout->addWidget(normalSizeButton);
 
// This button maximize the widget size
QPushButton* maximzeButton = new QPushButton("Maximize");
QObject::connect(maximzeButton, SIGNAL(clicked()), this, SLOT(showMaximized()));
layout->addWidget(maximzeButton);
 
// This button exit the application
QPushButton* exitButton = new QPushButton("Exit");
QObject::connect(exitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
layout->addWidget(exitButton);
}

Output Image

Image:Customnormal.jpg

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fHowE5ftoE5fdisplayE5fwidgetE5fwithE5fnormalE5fsizeE5fandE5fmaE78imizeX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZE71tQ qfnZtopicQUqfnTopicZseriesE5f60Q qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qfnZuserE5ftagQSxE71tX qfnZuserE5ftagQSxs60X qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ