canardman
canardman

Reputation: 3263

Delete child from QDialog::layout

class MyDialog : public QDialog
{
    public:
    MyDialog(QListWidget * w)
        : m_w(w)
    {
        m_layout = new QGridLayout(this);
        m_layout.addWidget( w );

        this->exec();
    } 

    ~MyDialog() {
        m_layout->removeWidget( m_w );
    }

    private:
    QGridLayout * m_layout;
    QListWidget * m_w;  
    }  

w is also a child of the main's window layout. The problem is when an object of MyDialog is destroy, it destroy w too whereas it was remove in the MyDialog's destructor;

Have you got a better solution than clone the QListWidget w ?

Upvotes: 0

Views: 318

Answers (1)

Belkrr
Belkrr

Reputation: 11

I think you can do smf like this:

~MyDialog()
{
   m_w.reparent(main_window);
}

But i think you doin smf wrog if you have to clone QListView. Is't it easy to make context menu for QListView and run this dialog for specific QListViewItem?

Upvotes: 1

Related Questions