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 dest开发者_JAVA百科roy, it destroy w too whereas it was remove in the MyDialog's destructor;
Have you got a better solution than clone the QListWidget w ?
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?
                                        
                                        
                                        
                                        
                                        
                                        
                                        
                                        
 加载中,请稍侯......
      
精彩评论