PDA

View Full Version : New to QSplitter



bruccutler
25th June 2007, 22:42
Hello,
I have two controls, one a QTreeWidget and another a QStackedDialog.

When I add these to a QSplitter and I attempt to drag the splitter, it flashes, but goes back to the original size. If I drag it far enough, the whole screen is replaced either by the left side or the right side, but I can't get it to stretch. I'm adding QGroupBoxes to the splitter, could that be my problem?

- BRC

Here's my code snippet:

QSplitter *splitter = new QSplitter(this);
splitter->addWidget(m_pNavGroupBox); // QGroupBox
splitter->addWidget(m_pDataGroupBox); // QGroupBox
splitter->setStretchFactor(0, 10);
splitter->setStretchFactor(1, 10);

QVBoxLayout *pMainLayout = new QVBoxLayout();
pMainLayout->addWidget(m_pTitleImageLabel, 3, Qt::AlignCenter); // label -
pMainLayout->addWidget(splitter);

setLayout(pMainLayout); // for main window

bruccutler
25th June 2007, 23:22
I hate to keep answering my own questions, but just in case someone else tries this, I had a tabbed dialog on the right hand side that had a tab that would not shrink, so, until I increased the size of the window, I couldn't drag the splitter bar. Once I eliminated that particular tab, I found that I could move it.

In my case I had stacked dialogs and the dialogs had tabbed dialogs underneath and one of the tabbed dialogs wouldn't fit in a smaller area, so none of them would.

ntp
30th August 2007, 19:52
I am running into the same problem. It has to do with layouts in the tabs.

I have a tab widget in one part of my splitter. As long as I have a layout in the tabs, I cannot make the splitter shrink that side. I need the layouts because I want the tab to look nice :) but is there any way to tell it that it can shrink that side?

I have a QMdiArea on the other side and I am able to shrink that side.

Thanks.

QTmplayer
30th August 2007, 21:23
Hi
Maybe some of the widgets' minimum size(hint) is too great, so that the layout prevents the splitter from further shrinking them.
Hope this helps.

ntp
30th August 2007, 21:56
I checked and I have no minimum sizes on any of the widgets and I set all the policies to preferred. (The only things I left as expanding were the spacers.)

I even created a minimumSizeHint() method to return (0,0) for each of the tabs but that didn't make a difference.

Thanks for the suggestions.

jpn
31st August 2007, 14:32
Did you create the form in designer? Sometimes spacers get relatively large size hint values while working with designer. I suggest you to go through spacers and check their size hints.

ntp
6th September 2007, 17:43
Somewhere along the way my tabWidget->setMinimumWidth(20); got deleted. Putting that back in fixed it. I have set my layouts to be minimum, minimumExpanding, and a few preferred. I also have removed all minimumWidths. I think the combination of all three solved the problem.