ui
->treeWidget
->setVerticalScrollMode
(QListView::ScrollPerPixel);
for(int i = 0; i <= 2; i++ ) {
rootItem->setText(0, "Folder Name");
ui->treeWidget->setColumnCount(1);
ui->treeWidget->insertTopLevelItem(0, rootItem);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
//sizePolicy.setHeightForWidth(filesView->sizePolicy().hasHeightForWidth());
sizePolicy.setHeightForWidth(true);
qDebug() << sizePolicy.hasHeightForWidth();
filesView
->setLayoutMode
(QListView::SinglePass);
filesView->setLayout(layout);
filesView->setModel(filesViewModel);
filesView->ensurePolished();
//filesView->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Expanding);
filesView->setSizePolicy(sizePolicy);
filesView->setWrapping(true);
//filesView->setMinimumHeight(100);
filesView->setWordWrap(true);
qDebug() << layout->hasHeightForWidth();
qDebug() << layout->heightForWidth(200);
// this should return true
qDebug() << layout->hasHeightForWidth();
for(int j = 0; j <= 20; j++ ) {
FileWidget *fileWidget = new FileWidget;
fileWidget
->ui
->label
->setText
(QString::number(j
));
fileItem->setSizeHint(fileWidget->size());
filesViewModel->appendRow(fileItem);
filesView->setIndexWidget(fileItem->index(),fileWidget);
filesView->resize(filesView->contentsRect().width(),
filesView->heightForWidth(filesView->contentsRect().width()));
fileItem->setSizeHint(fileWidget->size());
}
childItem->setText(0, "FILES VIEW HERE");
rootItem->insertChild(0, childItem);
ui->treeWidget->setItemWidget(childItem, 0, filesView);
filesView->resize(filesView->contentsRect().width(),
filesView->heightForWidth(filesView->contentsRect().width()));
childItem->setSizeHint(0,filesView->size());
}
ui->treeWidget->setVerticalScrollMode(QListView::ScrollPerPixel);
for(int i = 0; i <= 2; i++ ) {
QTreeWidgetItem *rootItem = new QTreeWidgetItem();
rootItem->setText(0, "Folder Name");
ui->treeWidget->setColumnCount(1);
ui->treeWidget->insertTopLevelItem(0, rootItem);
QStandardItemModel *filesViewModel = new QStandardItemModel;
QListView *filesView = new QListView;
QHBoxLayout *layout = new QHBoxLayout;
QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
//sizePolicy.setHeightForWidth(filesView->sizePolicy().hasHeightForWidth());
sizePolicy.setHeightForWidth(true);
qDebug() << sizePolicy.hasHeightForWidth();
filesView->setLayoutMode(QListView::SinglePass);
filesView->setLayout(layout);
filesView->setModel(filesViewModel);
filesView->ensurePolished();
filesView->setViewMode(QListView::IconMode);
filesView->setFlow(QListView::LeftToRight);
filesView->setResizeMode(QListView::Adjust);
//filesView->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Expanding);
filesView->setSizePolicy(sizePolicy);
filesView->setMovement(QListView::Free);
filesView->setWrapping(true);
//filesView->setMinimumHeight(100);
filesView->setWordWrap(true);
qDebug() << layout->hasHeightForWidth();
qDebug() << layout->heightForWidth(200);
// this should return true
qDebug() << layout->hasHeightForWidth();
for(int j = 0; j <= 20; j++ ) {
QStandardItem *fileItem = new QStandardItem;
FileWidget *fileWidget = new FileWidget;
fileWidget->ui->label->setText(QString::number(j));
fileItem->setSizeHint(fileWidget->size());
filesViewModel->appendRow(fileItem);
filesView->setIndexWidget(fileItem->index(),fileWidget);
filesView->resize(filesView->contentsRect().width(),
filesView->heightForWidth(filesView->contentsRect().width()));
fileItem->setSizeHint(fileWidget->size());
}
QTreeWidgetItem *childItem = new QTreeWidgetItem();
childItem->setText(0, "FILES VIEW HERE");
rootItem->insertChild(0, childItem);
ui->treeWidget->setItemWidget(childItem, 0, filesView);
filesView->resize(filesView->contentsRect().width(),
filesView->heightForWidth(filesView->contentsRect().width()));
childItem->setSizeHint(0,filesView->size());
}
To copy to clipboard, switch view to plain text mode
Bookmarks