Qt::Failing to Add QWidget as a parent to QListView



  • Well I am facing an issue related to layout. I have a class by name AVCHDClipListWidget which is inherited from QWidget. By using QVBoxLayout, I am setting the layout of this ListWidget as follows:

    @m_pAVCHDClipListWidget = new AVCHDClipListWidget(this);
    QWidget *pListWidget = new QWidget();
    QVBoxLayout *playout = new QVBoxLayout(pListWidget);
    playout->setSpacing(m_layoutSpacing);@
    
    @m_pAVCHDClipListWidget->setFixedHeight(m_topMargin);
    m_pAVCHDClipListWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
    playout->addWidget(m_pAVCHDClipListWidget);@
    

    When I create the object for AVCHDClipListWidget class, the constructor executes the following statements:

    @m_pSecondaryListView = new AVCHDBinListView(this);
    QGridLayout *pgridlayout = new QGridLayout(this);
    
    m_pSecondaryListView->setEditTriggers(QListView::NoEditTriggers);
    pgridlayout->addWidget(m_pSecondaryListView);@
    

    Here AVCHDBinListView is a class which inherits from QListView. When I execute this code, I get a listview with the fixed height and expandable width as shown in the above code.

    But I need a widget which surrounds it. Basically a Qwidget, inside which this list view should be visible. I am failing to achieve it. Please help :)



  • well... the easiest way would be to set the layout of the surrounding widget which you want with the Listview you want... I used the class names because the names you provided are too long but basically this is what you need to do...

    @QWidget::setLayout(QListView);
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.