×
Namespaces

Variants
Actions
Revision as of 04:13, 11 October 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

How to use QGraphicsProxyWidget in Qt

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): S60 Emulator
Compatibility
Platform(s): Qt
Symbian
Platform Security
Signing Required: Self-Signed
Capabilities: None
Article
Keywords: QGraphicsProxyWidget,QGraphicsScene,QGraphicsView,QLineEdit,QLabel
Created: mind_freak (10 Apr 2009)
Last edited: hamishwillee (11 Oct 2012)

Contents

Introduction

The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene. QGraphicsProxyWidget embeds QWidget-based widgets, for example, a QPushButton, QFontComboBox, or even QFileDialog, into QGraphicsScene. It forwards events between the two objects and translates between QWidget's integer-based geometry and QGraphicsWidget's qreal-based geometry.

QGraphicsProxyWidget takes care of automatically embedding popup children of embedded widgets through creating a child proxy for each popup.

Souce Code

Main.cpp

#include "proxywidget.h"
 
#include <QtGui>
#include <QApplication>
#include<QGroupBox>
#include<QFormLayout>
#include<QLabel>
#include<QLineEdit>
#include<QGraphicsScene>
#include<QGraphicsProxyWidget>
#include<QGraphicsView>
#include<QPushButton>
#include<QComboBox>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QGroupBox *groupBox = new QGroupBox("Contact Details",this);
QLabel *numberLabel = new QLabel("Telephone number",this);
QLineEdit *numberEdit = new QLineEdit(this);
QPushButton *but=new QPushButton("Helloooo",this);
QFormLayout *layout = new QFormLayout;
QComboBox *box=new QComboBox(this);
box->addItem("Nokia");
box->addItem("Qt");
box->addItem("Widget");
box->addItem("N96");
box->addItem("London");
box->addItem("Finland");
box->addItem("NewYork");
box->addItem("Symbian");
box->addItem("Paris");
box->addItem("Budapest");
layout->addRow(numberLabel, numberEdit);
layout->addRow(but);
layout->addRow(box);
groupBox->setLayout(layout);
 
QGraphicsScene scene;
QGraphicsProxyWidget *proxy = scene.addWidget(groupBox);
QGraphicsView view(&scene);
view.show();
return a.exec();
}

ScreenShot

Before Clicking The ComboBox

Note the changes in the scrollBar of the widget

More about QGraphicProxyWidget

Mescreen001.jpg

This page was last modified on 11 October 2012, at 04:13.
128 page views in the last 30 days.
×