Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

How to use QFrame in Qt

From Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Symbian emulator
Compatibility
Platform(s): Qt
Symbian
Article
Keywords: QFrame
Created: james1980 (31 Dec 2008)
Last edited: hamishwillee (11 Oct 2012)

Contents

Introduction

Qt provides the QFrame class which can be use to make a frame around the widget. You can make your application more attractive by using one of the type of frame given in this class.

QFrame is used as a base class for numerous widgets of Qt: QAbstractScrollArea, QLabel, QLCDNumber, QSplitter, QStackedWidget, and QToolBox. The examples of this page show the various frame around the label widget (QLabel).

Various Function

Frame Style

The frame style is defined by the combination of a frame shape and a shadow style.

label->setFrameStyle(QFrame::Box | QFrame::Raised);
label->setLineWidth(2);
label1->setFrameStyle(QFrame::Box | QFrame::Sunken);
label1->setLineWidth(2);
Saveraised.JPG

Frame Shape

label1->setFrameShape(Qt::StyledPanel);
Stylepanel.JPG

More information

For more functions and property visit: http://doc.trolltech.com/4.5/qframe.html

Code

#include <QApplication>
#include <QLabel>
#include <QFrame>
#include <QVBoxLayout>
#include <QWidget>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget *win = new QWidget;
 
QLabel *label = new QLabel("Box");
QLabel *label1 = new QLabel("Panel");
QLabel *label2 = new QLabel("Winpanel");
QLabel *label3 = new QLabel("H line");
QLabel *label4 = new QLabel("V line");
QLabel *label5 = new QLabel("Styled Panel");
 
label->setFrameStyle(QFrame::Box | QFrame::Raised);
label->setLineWidth(2);
label1->setFrameStyle(QFrame::Panel | QFrame::Raised);
label1->setLineWidth(2);
label2->setFrameStyle(QFrame::WinPanel | QFrame::Raised);
label2->setLineWidth(2);
label3->setFrameStyle(QFrame::HLine | QFrame::Raised);
label3->setLineWidth(2);
label4->setFrameStyle(QFrame::VLine | QFrame::Raised);
label4->setLineWidth(2);
label5->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
label5->setLineWidth(2);
 
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(label);
layout->addWidget(label1);
layout->addWidget(label2);
layout->addWidget(label3);
layout->addWidget(label4);
layout->addWidget(label5);
win->setLayout(layout);
win->show();
return app.exec();
}

Frame.jpg

This page was last modified on 11 October 2012, at 01:17.
604 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.

×