| 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 |
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.
#include <QApplication>
#include "customwidget.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
CustomWidget w;
w.show();
return a.exec();
}
#ifndef CUSTOMWIDGET_H
#define CUSTOMWIDGET_H
#include <QWidget>
class CustomWidget : public QWidget
{
Q_OBJECT
public:
CustomWidget(QWidget *parent = 0);
};
#endif // CUSTOMWIDGET_H
#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);
}
No related wiki articles found