How can I make a child widget standalone?

Viewed 3214

Suppose I have a main Widget, which is used to view some objects. The names of those objects are stored in a QListWidget. Now when a user selects one object (one item of the QListWidget), I want to open another widget in a separate window which takes the name of the object as an argument.

class MainWidget
{
Q_OBJECT

public slots:
    void openSelection();

};

class ChildWidget
{
public:
    ChildWidget(QString name, QWidget* parent = nullptr);
};

void MainWidget::openSelection()
{
    QString selectedObjectName = ui->objectsNamesList->selectedItem()->text();
    ChildWidget* detaildedWiew = new ChildWidget(selectedObjectName, this);
    detaildedWiew->show();
}

When I do this, the child widget opens, but it has no space of its own. It is locked in the area of the parent. I need to set the children free, to run around the screen freely, independent of their parent. How can I do this? Is there some Qt way, or do I have to define some "pseudo child" relationship and develop a system to properly delete the pseudo children?

2 Answers
Related