I am facing an issue related to displaying widgets. I have a QWidget inside which I wanna display a QListView. To illustrate further, here is the scenario:
I have a QWidget which I am adding to a vertical layout first. Then I have a class `ClipWidget` which inherits from `QWidget`. By using `QVBoxLayout`, I am setting the layout of this `Widget` as follows:
QWidget *pListWidget = new QWidget(this);
QWidget *pWidget = new QWidget(this);
QVBoxLayout *playoutwid = new QVBoxLayout(pWidget);
playoutwid->setSpacing(0);
playoutwid->addWidget(pListWidget)
m_pClipWidget = new ClipWidget(pListWidget);
QWidget *pClip = new QWidget();
QVBoxLayout *playout = new QVBoxLayout(pClip);
playout->setSpacing(0);
m_pClipWidget->setFixedHeight(120);
m_pClipWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
playout->addWidget(m_pClipWidget)
If you notice, I am passing the QWidget object in my ClipWidget class as follows:
m_pClipWidget = new ClipWidget(pListWidget);
I have fixed the height of `m_pClipWidget` and I have set the width as expanding. With this my intention is to have this fixed `m_pClipWidget` inside a QWidget `pListWidget`.
Now When I create an instance of `ClipWidget`, the constructor executes the following statements:
m_pSecondaryListView = new BinListView(this);
QGridLayout *pgridlayout = new QGridLayout(this);
pgridlayout->addWidget(m_pSecondaryListView);
Here `BinListView` is a class which inherits from `QListView`. With this approach, I am looking forward to display `ClipWidget` inside the `pListWidget` but when I execute the code, it doesn’t display.
Ideally I should get a `BinListView` with the fixed height of 120 and expandable width inside a QWidget. Am I missing something???
Please help :)
↧