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 QGraphicsProxyWidget in Qt

From 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 01:13.
129 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.

×