Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt::Failing to Add QWidget as a parent to QListView
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 944 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Stoned Jesus
    wrote on last edited by
    #1

    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 :)

    --
    Thanks & Regards,
    Stoned Jesus

    1 Reply Last reply
    0
    • B Offline
      B Offline
      b1gsnak3
      wrote on last edited by
      #2

      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);
      @

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved