Splitter between items in a QTreeView - qt

I want to resize an items height in a QTreeView separately for each item.
Is there an easy way to make splitters between each items in a QTreeView?

Related

QListWidget resize contents when splitter changes size

I have a QListWidget with some widgets inside:
QListWidgetItem* w = new QListWidgetItem(ui->listWidget);
ui->listWidget->addItem(w);
w->setSizeHint(widget->sizeHint());
ui->listWidget->setItemWidget(w, widget);
However, everything seems to work fine until I resize the the QListWidget (it is embedded into a QDockwidget). Do I have to iterate over all items and resize them manually or is there a simple trick?
It is just a list with items having a button on the left and a button on the right. If the list gets resized (QSize changes) than the buttons gets hidden and a scrollbar appears. I want to have the size of the item according to the list width.
Try setting the resizeMode property to Adjust. This will cause your QListWidget to automatically resize all of the items in the view to the size of the QListWidget anytime the widget is resized.
See the documentation here. Your code will be structured like so:
QListWidgetItem* w = new QListWidgetItem(ui->listWidget);
w->setSizeHint(widget->sizeHint());
ui->listWidget->setResizeMode(QListView::Adjust);
ui->listWidget->addItem(w);
ui->listWidget->setItemWidget(w, widget);
EDIT: Depending on the uniformity of your items, you may also benefit from setting the uniformItemSizes property. QListView can optimize the layout of your view if you set this property.

expanding widgets inside a Qtabwidget

Why does the widgets inside a QTabWidget don't resize?
All my widgets resize except for the ones inside the tabs, even the tabs resize, but not the items inside it.
Is this because of the type of layout as I show in the figure?
I can's assign a layout to it. this is before and after maximizing the window.
Why can't you assign a layout to it? You just have to give each tab a layout. Drag your widget into the tab. Select the tab, not the widget, click on one of the layouts in the top row of the designer. Your widget will fill the whole tab and resize nicely.

Qt Layout Flexible Grid

I have a bunch of buttons in Qt with a fixed size. Now I want to create a layout in which they are shown in a grid. I want the grid to be scrollable and when I resize my mainwindow, the grid should fit as much buttons in the layout as possible. The number of rows and columns are therefore not fixed.
I tried creating this with the hbox, vbox and gridlayout but they either put all the buttons below each other, or side by side. Also it resizes my mainwindow to an enormous size to fit all the buttons in.
Any Ideas?
Put QScrollArea inside your QMainWindow. Apply QGridLayout to QScrollArea's inside widget and put the buttons inside it.

Can a background image be larger than the qlistview item?

I'm working on an app in which I'm using a QStandardItemModel. Every item in QstandardItemModel is a thumbnail with text. These items are bound in a QListView which are in a layout.
Is it possible to set a background for each of the QListview items such that the background is larger than the item? Or is it possible to add a frame to the item?
Yes, you can add a frame to the item index of item, and you can set a background to each item, but I didn't understand your need to do that. I mean, if you background may be larger than item, why don't you set a whole QListView background instead?
Edit: How to add a frame to an item:
QFrame *frame = new QFrame(this); //or any other widget-type object.
ui->listView->setIndexWidget(ui->listView->model()->index(0,0), frame); //set to desired index.

Qt subwidget automatic resizing in QHBoxLayout

I have a QTableView. When the table grows, the table view adds scrollbars, even when it could just expand to take more room in the QHBoxLayout. How do I make it expand?

Resources