Sometimes a complex embedded widget will produce a very large node(personally, I think it's ugly). there are also windows that need to be very large, but resize() does not solve our problem, e.g. ImageShowModel.
So I wondered if there could be an option for us to decide if the embedded widget for node actually needs to be embedded in node.
bool widgetEmbeded() const { return true; }
Here I have written a simple example. to show the original node and the modified node.
Before:
The image size I show here is 1082x602, and to see the detail you need to zoom in to quite a large size, and it is cumbersome to manipulate.
After:
In this example I don't embed the widget in the node, instead I use a double click on the node to generate the dockwidget. Of course, any window can now call node's embeddedWidget(). If this is the case, I am also able to zoom in and out in the image display, etc.
connect(
_scene, &DataFlowGraphicsScene::nodeDoubleClicked, this, [this](QtNodes::NodeId nodeId) {
QString name = _graphModel->nodeData(nodeId, QtNodes::NodeRole::Type).value<QString>();
bool isEmbeded =
_graphModel->nodeData(nodeId, QtNodes::NodeRole::WidgetEmbeded).value<bool>();
auto w = _graphModel->nodeData(nodeId, QtNodes::NodeRole::Widget).value<QWidget *>();
if (!isEmbeded && w) {
QDockWidget *dock = new QDockWidget(name, this);
dock->setWidget(w);
this->addDockWidget(Qt::LeftDockWidgetArea, dock);
}
});
In addition I can choose whether to embed or not via the bool variable, as there are some very simple widgets that might look better with an embed approach.
Sometimes a complex embedded widget will produce a very large node(personally, I think it's ugly). there are also windows that need to be very large, but
resize()
does not solve our problem, e.g.ImageShowModel
.So I wondered if there could be an option for us to decide if the embedded widget for node actually needs to be embedded in node.
bool widgetEmbeded() const { return true; }
Here I have written a simple example. to show the original node and the modified node.
Before: The image size I show here is 1082x602, and to see the detail you need to zoom in to quite a large size, and it is cumbersome to manipulate.
After: In this example I don't embed the widget in the node, instead I use a double click on the node to generate the dockwidget. Of course, any window can now call node's
embeddedWidget()
. If this is the case, I am also able to zoom in and out in the image display, etc.In addition I can choose whether to embed or not via the
bool
variable, as there are some very simple widgets that might look better with an embed approach.