| ID | ... | Creation date | 06 January 2009 |
| Platform | S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition | Tested on devices | Emulator |
| Category | Qt for Symbian | Subcategory | Stylesheet |
| Keywords (APIs, classes, methods, functions): setStylesheet, Push Button, Text Label |
This code snippet demonstrates how to create a stylesheet and apply the style to the individual widget in Qt for S60.
win->setStyleSheet("* { color: #676767;border-style:dashed ; border-width: 4px; bord er- color: #00FFFF; padding: 7px}}");
#include <QApplication>
#include <QPushButton>
#include <QLabel>
#include <QWidget>
#include <QVBoxLayout>
#include<QLineEdit>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget *win = new QWidget;
QVBoxLayout *layout = new QVBoxLayout;
QPushButton *button = new QPushButton("Click");
QLabel *label = new QLabel("Hello");
QLineEdit *line=new QLineEdit();
win->setStyleSheet("* { color: #676767;border-style:dashed ; border-width: 4px; border-color: #00FFFF; padding: 7px}}");
button->setStyleSheet("* { background-color: rgb(255,125,100) }");
label->setStyleSheet("* { background-color: blue }");
line->setStyleSheet("*{background-color:yellow}");
layout->addWidget(label);
layout->addWidget(button);
layout->addWidget(line);
win->setLayout(layout);
win->showMaximized();
return app.exec();
}