QListView in QSplitter not using entire available size.
-
Hello,
I have a QTableView, QLineEdit and QListView in a QDockWidget and use a QSplitter for the layout. I get a lot of free space which I would like the QListView to have. I have used multiple functions found in QtDocs, but none of them let me change the size of the QListView. If I remove the QListView from the QSplitter, the space is nicely distributed between QTableView and QLineEdit, so I'm assuming I'm doing something wrong with the QListView. Picture 1 is the current state and picture 2 is what I want to have.


-
Hello,
I have a QTableView, QLineEdit and QListView in a QDockWidget and use a QSplitter for the layout. I get a lot of free space which I would like the QListView to have. I have used multiple functions found in QtDocs, but none of them let me change the size of the QListView. If I remove the QListView from the QSplitter, the space is nicely distributed between QTableView and QLineEdit, so I'm assuming I'm doing something wrong with the QListView. Picture 1 is the current state and picture 2 is what I want to have.


-
One possibility is that you have
setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);@VRonin Thanks, I can do that, but I want the QListView have to fill the entire space that is left. If I change the policy to QAbstractScrollArea::AdjustToContents, the QListView will be adjusted to the needs of the contents. I.e.: if the contents only need a small amount of space, then the QListView also be very small.
-
@VRonin Thanks, I can do that, but I want the QListView have to fill the entire space that is left. If I change the policy to QAbstractScrollArea::AdjustToContents, the QListView will be adjusted to the needs of the contents. I.e.: if the contents only need a small amount of space, then the QListView also be very small.
-
@YokeM Yes, sorry, I was actually highlighting it as a possible cause of the problem. I wasn't clear.
Can you show the code you use to add the widgets to the splitter?
@VRonin Sure:
ListView:
.h:
class... { ... QListView *listView; }.cpp:
void func ... { ... listView = new QListView(this); listView->setModel(listModel); listView->setEditTriggers(QAbstractItemView::NoEditTriggers); }Splitter:
.h:
class... { ... QSplitter *componentSplitter; }.cpp:
void func ... { ... componentSplitter = new QSplitter(this); componentSplitter->setOrientation(Qt::Vertical); componentSplitter->setChildrenCollapsible(false); componentSplitter->addWidget(descriptionComponent); } -
The code you posted is missing the key link. how does
listViewend up incomponentSplitter? -
Hi,
The problem is that with your code, you have one class with a QListView and another one with a QSplitter, how are they connected to each other ?