|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.gui.QGraphicsWidget
com.trolltech.qt.gui.QGraphicsProxyWidget
public class QGraphicsProxyWidget
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene. QGraphicsProxyWidget embeds any QWidget-based widget, 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 supports all core features of QWidget, including tab focus, keyboard input, Drag & Drop, and popups. You can also embed complex widgets, e.g., widgets with subwidgets.
Example:
The following code example is written in c++.
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QTabWidget *tabWidget = new QTabWidget;
QGraphicsScene scene;
QGraphicsProxyWidget *proxy = scene.addWidget(tabWidget);
QGraphicsView view(&scene);
view.show();
return app.exec();
}
QGraphicsProxyWidget takes care of automatically embedding popup children of embedded widgets through creating a child proxy for each popup. This means that when an embedded QComboBox shows its popup list, a new QGraphicsProxyWidget is created automatically, embedding the popup, and positioning it correctly.QGraphicsProxyWidget. The most common way is to pass a widget pointer to QGraphicsScene::addWidget() together with any relevant Qt::WindowFlags. This function returns a pointer to a QGraphicsProxyWidget. You can then choose to reparent or position either the proxy, or the embedded widget itself. For example, in the code snippet below, we embed a group box into the proxy:
The following code example is written in c++.
QGroupBox *groupBox = new QGroupBox("Contact Details");
QLabel *numberLabel = new QLabel("Telephone number");
QLineEdit *numberEdit = new QLineEdit;
QFormLayout *layout = new QFormLayout;
layout->addRow(numberLabel, numberEdit);
groupBox->setLayout(layout);
QGraphicsScene scene;
QGraphicsProxyWidget *proxy = scene.addWidget(groupBox);
QGraphicsView view(&scene);
view.show();
The image below is the output obtained with its contents margin and contents rect labeled. 
QGraphicsProxyWidget item, and then call setWidget() to embed a QWidget later. The widget() function returns a pointer to the embedded widget. QGraphicsProxyWidget shares ownership with QWidget, so if either of the two widgets are destroyed, the other widget will be automatically destroyed as well.QGraphicsProxyWidget keeps its state in sync with the embedded widget. For example, if the proxy is hidden or disabled, the embedded widget will be hidden or disabled as well, and vice versa. When the widget is embedded by calling addWidget(), QGraphicsProxyWidget copies the state from the widget into the proxy, and after that, the two will stay synchronized where possible. By default, when you embed a widget into a proxy, both the widget and the proxy will be visible because a QGraphicsWidget is visible when created (you do not have to call show()). If you explicitly hide the embedded widget, the proxy will also become invisible. Example:
The following code example is written in c++.
QGraphicsScene scene;
QLineEdit *edit = new QLineEdit;
QGraphicsProxyWidget *proxy = scene.addWidget(edit);
edit->isVisible(); // returns true
proxy->isVisible(); // also returns true
edit->hide();
edit->isVisible(); // returns false
proxy->isVisible(); // also returns false
}
QGraphicsProxyWidget maintains symmetry for the following states: QGraphicsScene keeps the embedded widget in a special state that prevents it from disturbing other widgets (both embedded and not embedded) while the widget is embedded. In this state, the widget may differ slightly in behavior from when it is not embedded. QGraphicsScene::addWidget(), and QGraphicsWidget.
| Nested Class Summary | |
|---|---|
static class |
QGraphicsProxyWidget.enum_1
|
| Nested classes/interfaces inherited from class com.trolltech.qt.QtJambiObject |
|---|
QtJambiObject.QPrivateConstructor |
| Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
|---|
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I> |
| Constructor Summary | |
|---|---|
|
QGraphicsProxyWidget()
Constructs a new QGraphicsProxy widget. |
|
QGraphicsProxyWidget(QGraphicsItemInterface parent)
Constructs a new QGraphicsProxy widget. |
|
QGraphicsProxyWidget(QGraphicsItemInterface parent,
Qt.WindowFlags wFlags)
Constructs a new QGraphicsProxy widget. |
|
QGraphicsProxyWidget(QGraphicsItemInterface parent,
Qt.WindowType... wFlags)
Constructs a new QGraphicsProxy widget. |
protected |
QGraphicsProxyWidget(QtJambiObject.QPrivateConstructor p)
This method is internal to Qt Jambi. |
| Method Summary | |
|---|---|
void |
contextMenuEvent(QGraphicsSceneContextMenuEvent event)
|
boolean |
event(QEvent event)
|
boolean |
eventFilter(QObject object,
QEvent event)
|
void |
focusInEvent(QFocusEvent event)
|
protected boolean |
focusNextPrevChild(boolean next)
|
void |
focusOutEvent(QFocusEvent event)
|
static QGraphicsProxyWidget |
fromNativePointer(QNativePointer nativePointer)
|
protected void |
grabMouseEvent(QEvent event)
|
protected void |
hideEvent(QHideEvent event)
|
void |
hoverEnterEvent(QGraphicsSceneHoverEvent event)
|
void |
hoverLeaveEvent(QGraphicsSceneHoverEvent event)
|
void |
hoverMoveEvent(QGraphicsSceneHoverEvent event)
|
java.lang.Object |
itemChange(QGraphicsItem.GraphicsItemChange change,
java.lang.Object value)
|
void |
keyPressEvent(QKeyEvent event)
|
void |
keyReleaseEvent(QKeyEvent event)
|
void |
mouseDoubleClickEvent(QGraphicsSceneMouseEvent event)
|
void |
mouseMoveEvent(QGraphicsSceneMouseEvent event)
|
void |
mousePressEvent(QGraphicsSceneMouseEvent event)
|
void |
mouseReleaseEvent(QGraphicsSceneMouseEvent event)
|
void |
paint(QPainter painter,
QStyleOptionGraphicsItem option,
QWidget widget)
|
protected void |
resizeEvent(QGraphicsSceneResizeEvent event)
|
void |
setGeometry(QRectF rect)
|
void |
setWidget(QWidget widget)
Embeds widget into this proxy widget. |
protected void |
showEvent(QShowEvent event)
|
QSizeF |
sizeHint(Qt.SizeHint which,
QSizeF constraint)
|
QRectF |
subWidgetRect(QWidget widget)
Returns the rectangle for widget, which must be a descendant of widget(), or widget() itself, in this proxy item's local coordinates. |
int |
type()
|
protected void |
ungrabMouseEvent(QEvent event)
|
void |
wheelEvent(QGraphicsSceneWheelEvent event)
|
QWidget |
widget()
Returns a pointer to the embedded widget. |
| Methods inherited from class com.trolltech.qt.core.QObject |
|---|
blockSignals, childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent, toString, userProperty |
| Methods inherited from class com.trolltech.qt.QtJambiObject |
|---|
disableGarbageCollection, dispose, disposed, equals, finalize, nativeId, nativePointer, reassignNativeResources, reenableGarbageCollection, setJavaOwnership, tr, tr, tr |
| Methods inherited from class com.trolltech.qt.QSignalEmitter |
|---|
__qt_signalInitialization, disconnect, disconnect, signalSender |
| Methods inherited from class java.lang.Object |
|---|
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.trolltech.qt.QtJambiInterface |
|---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
| Constructor Detail |
|---|
public QGraphicsProxyWidget(QGraphicsItemInterface parent,
Qt.WindowType... wFlags)
QGraphicsItem's constructor.
public QGraphicsProxyWidget(QGraphicsItemInterface parent)
QGraphicsItem's constructor.
public QGraphicsProxyWidget()
QGraphicsItem's constructor.
public QGraphicsProxyWidget(QGraphicsItemInterface parent,
Qt.WindowFlags wFlags)
QGraphicsItem's constructor.
protected QGraphicsProxyWidget(QtJambiObject.QPrivateConstructor p)
| Method Detail |
|---|
public final void setWidget(QWidget widget)
widget must be a top-level widget whose parent is 0.
When the widget is embedded, its state (e.g., visible, enabled, geometry, size hints) is copied into the proxy widget. If the embedded widget is explicitly hidden or disabled, the proxy widget will become explicitly hidden or disabled after embedding is complete. The class documentation has a full overview over the shared state.
After this function returns, QGraphicsProxyWidget will keep its state synchronized with that of widget whenever possible.
If a widget is already embedded by this proxy when this function is called, that widget will first be automatically unembedded. Passing 0 for the widget argument will only unembed the widget, and the ownership of the currently embedded widget will be passed on to the caller.
widget().
public final QRectF subWidgetRect(QWidget widget)
widget(), or widget() itself, in this proxy item's local coordinates. If no widget is embedded, widget is 0, or widget is not a descendant of the embedded widget, this function returns an empty QRectF.
widget().
public final QWidget widget()
setWidget().
public void contextMenuEvent(QGraphicsSceneContextMenuEvent event)
contextMenuEvent in interface QGraphicsItemInterfacecontextMenuEvent in class QGraphicsWidgetpublic boolean event(QEvent event)
event in class QGraphicsWidget
public boolean eventFilter(QObject object,
QEvent event)
eventFilter in class QObjectpublic void focusInEvent(QFocusEvent event)
focusInEvent in interface QGraphicsItemInterfacefocusInEvent in class QGraphicsWidgetprotected boolean focusNextPrevChild(boolean next)
focusNextPrevChild in class QGraphicsWidgetpublic void focusOutEvent(QFocusEvent event)
focusOutEvent in interface QGraphicsItemInterfacefocusOutEvent in class QGraphicsWidgetprotected void grabMouseEvent(QEvent event)
grabMouseEvent in class QGraphicsWidgetprotected void hideEvent(QHideEvent event)
hideEvent in class QGraphicsWidgetpublic void hoverEnterEvent(QGraphicsSceneHoverEvent event)
hoverEnterEvent in interface QGraphicsItemInterfacehoverEnterEvent in class QGraphicsWidgetpublic void hoverLeaveEvent(QGraphicsSceneHoverEvent event)
hoverLeaveEvent in interface QGraphicsItemInterfacehoverLeaveEvent in class QGraphicsWidgetpublic void hoverMoveEvent(QGraphicsSceneHoverEvent event)
hoverMoveEvent in interface QGraphicsItemInterfacehoverMoveEvent in class QGraphicsWidget
public java.lang.Object itemChange(QGraphicsItem.GraphicsItemChange change,
java.lang.Object value)
itemChange in interface QGraphicsItemInterfaceitemChange in class QGraphicsWidgetpublic void keyPressEvent(QKeyEvent event)
keyPressEvent in interface QGraphicsItemInterfacekeyPressEvent in class QGraphicsWidgetpublic void keyReleaseEvent(QKeyEvent event)
keyReleaseEvent in interface QGraphicsItemInterfacekeyReleaseEvent in class QGraphicsWidgetpublic void mouseDoubleClickEvent(QGraphicsSceneMouseEvent event)
mouseDoubleClickEvent in interface QGraphicsItemInterfacemouseDoubleClickEvent in class QGraphicsWidgetpublic void mouseMoveEvent(QGraphicsSceneMouseEvent event)
mouseMoveEvent in interface QGraphicsItemInterfacemouseMoveEvent in class QGraphicsWidgetpublic void mousePressEvent(QGraphicsSceneMouseEvent event)
mousePressEvent in interface QGraphicsItemInterfacemousePressEvent in class QGraphicsWidgetpublic void mouseReleaseEvent(QGraphicsSceneMouseEvent event)
mouseReleaseEvent in interface QGraphicsItemInterfacemouseReleaseEvent in class QGraphicsWidget
public void paint(QPainter painter,
QStyleOptionGraphicsItem option,
QWidget widget)
paint in interface QGraphicsItemInterfacepaint in class QGraphicsWidgetprotected void resizeEvent(QGraphicsSceneResizeEvent event)
resizeEvent in class QGraphicsWidgetpublic void setGeometry(QRectF rect)
setGeometry in interface QGraphicsLayoutItemInterfacesetGeometry in class QGraphicsWidgetprotected void showEvent(QShowEvent event)
showEvent in class QGraphicsWidget
public QSizeF sizeHint(Qt.SizeHint which,
QSizeF constraint)
sizeHint in interface QGraphicsLayoutItemInterfacesizeHint in class QGraphicsWidgetpublic int type()
type in interface QGraphicsItemInterfacetype in class QGraphicsWidgetprotected void ungrabMouseEvent(QEvent event)
ungrabMouseEvent in class QGraphicsWidgetpublic void wheelEvent(QGraphicsSceneWheelEvent event)
wheelEvent in interface QGraphicsItemInterfacewheelEvent in class QGraphicsWidgetpublic static QGraphicsProxyWidget fromNativePointer(QNativePointer nativePointer)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||