Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

floating widget #373

Open
zmoth opened this issue Feb 20, 2023 · 0 comments · May be fixed by #374
Open

floating widget #373

zmoth opened this issue Feb 20, 2023 · 0 comments · May be fixed by #374

Comments

@zmoth
Copy link
Contributor

zmoth commented Feb 20, 2023

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.

image

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.

image

@zmoth zmoth linked a pull request Feb 20, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant