|
||||||||||||||||||||||||||||||||||||||||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||||||||||||||||||||||||||||||||||||||
SUMMARY: java.lang.Object
The QGraphicsProxyWidget class provides a proxy layer for embedding a Example: public static void main(String args[]) { QApplication.initialize(args); QTabWidget tabWidget = new QTabWidget(); QGraphicsScene scene = new QGraphicsScene(); QGraphicsProxyWidget proxy = scene.addWidget(tabWidget); QGraphicsView view = new QGraphicsView(scene); view.show(); QApplication.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.Embedding a Widget with QGraphicsProxyWidgetThere are two ways to embed a widget using QGraphicsProxyWidget. The most common way is to pass a widget pointer toQGraphicsScene::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: QGraphicsScene scene = new QGraphicsScene(); QLineEdit edit = new QLineEdit(); QGraphicsProxyWidget proxy = scene.addWidget(edit); edit.isVisible(); // returns false, as QWidget is hidden by default proxy.isVisible(); // also returns false edit.show(); edit.isVisible(); // returns true proxy.isVisible(); // returns trueThe image below is the output obtained with its contents margin and contents rect labeled. ![]() Alternatively, you can start by creating a new 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.Synchronizing Widget StatesQGraphicsProxyWidget 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 aQGraphicsWidget 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:Error parsing snippet. 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 .
QGraphicsProxyWidgetpublic QGraphicsProxyWidget(QGraphicsItemInterface parent, Qt.WindowType[] wFlags)
QGraphicsProxyWidgetpublic QGraphicsProxyWidget(QGraphicsItemInterface parent)
QGraphicsProxyWidgetpublic QGraphicsProxyWidget()
QGraphicsProxyWidgetpublic QGraphicsProxyWidget(QGraphicsItemInterface parent, Qt.WindowFlags wFlags)
|