2

I would like to insert a Q3DScatter instance onto one of my forms. I am able to construct the graph and display it with:

Q3DScatter *graph = new Q3DScatter();
QWidget *container = QWidget::createWindowContainer(graph);

...do some graph stuff...

container.show()

This successfully creates the graph and shows it in its own window/container. I would now like to place it inside another form that has been designed in qt-creator. I have placed an empty widget on the form(QDialog) as a placeholder, but am unable to move the Q3DScatter into the widget.

I see Q3DScatter::Q3DScatter(const QSurfaceFormat *format = Q_NULLPTR, QWindow *parent = Q_NULLPTR) in the documentation but I dont have a QWindow parent to attach it to, as the form I would like to add it to is a QDialog...

I am very new to widgets in general, so please correct me if this is the wrong approach.

1 Answer 1

2

Add the container as a child of the dialog. Put in a layout if you need to resize when the dialog is resized. Example:

MyDialog::MyDialog(Q3DScatter *scatter, QWidget *parent) : QDialog(parent)
{
    QHBoxLayout * const l = new QHBoxLayout(this);
    l->setMargin(0);
    l->addWidget(QWidget::createWindowContainer(scatter, this);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.