PDA

View Full Version : Make QTreeView cover the whole screen



hubbobubbo
8th April 2010, 11:49
Hi

I have a very simple layout. It is a QStackedWidget and inside this widget I display a QTreeView and below that a button, like this (the editor messes with the | on the right side so I removed them).

-------------------------
|
|
| QTreeView
|
|
|-----------------------|
| button
-------------------------

The problem is that there is a "margin" around the QTreeView i.e it does not go all the way out to the left, right and top, so it looks more like this:

-------------------------
||-----------------------
||
|| QTreeView
||-----------------------
|
|-----------------------|
| button
-------------------------

I just want the QTreeView to cover as much has possible of the screen. I have tried the CSS properties margin, border-width and padding but it did not make any difference, so I wonder:

How can I make the QTreeView go all the way out to the borders to maximize the screen utilization?

Thanks

aamer4yu
8th April 2010, 12:38
Are tree view and button in same widget of the current widget in QStackWidget ?
Try to set margins of the layout that treeview and button are in.

hubbobubbo
8th April 2010, 16:33
No, the StackedWidget is ontop of the buttons and they are put there with a QVboxLayout like this:

QVBoxLayout* vLayout = new QVBoxLayout(centralWidget);

vLayout->addWidget(stackedWidget); //This widget contains the QTreeView
vLayout->addLayout(button);

I have tried with the stylesheets and now also with setContentsMargin(0,0,0,0) both on the QTreeView and the StackedWidget which contains it but it has not changed anything.

hubbobubbo
8th April 2010, 17:10
Aha, it was the margins of the layout that was the problem. setMargin(0) on the layout solved the problem.