When you hide() a child its space will be distributed among the
other children. It will be reinstated when you show() it again.
+ \note Adding a QLayout to a QSplitter is not supported (either through
+ setLayout() or making the QSplitter a parent of the QLayout); use addWidget()
+ instead (see example above).
+
\sa QSplitterHandle, QHBoxLayout, QVBoxLayout, QTabWidget
*/
void QSplitter::childEvent(QChildEvent *c)
{
Q_D(QSplitter);
- if (!c->child()->isWidgetType())
+ if (!c->child()->isWidgetType()) {
+ if (c->type() == QEvent::ChildAdded && qobject_cast<QLayout *>(c->child()))
+ qWarning("Adding a QLayout to a QSplitter is not supported.");
return;
+ }
QWidget *w = static_cast<QWidget*>(c->child());
if (c->added() && !d->blockChildAdd && !w->isWindow() && !d->findWidget(w)) {
d->insertWidget_helper(d->list.count(), w, false);
void task169702_sizes();
void taskQTBUG_4101_ensureOneNonCollapsedWidget_data();
void taskQTBUG_4101_ensureOneNonCollapsedWidget();
-
+ void setLayout();
private:
void removeThirdWidget();
void addThirdWidget();
QVERIFY(s.sizes().at(0) > 0);
}
+void tst_QSplitter::setLayout()
+{
+ QSplitter splitter;
+ QVBoxLayout layout;
+ QTest::ignoreMessage(QtWarningMsg, "Adding a QLayout to a QSplitter is not supported.");
+ splitter.setLayout(&layout);
+ // It will work, but we don't recommend it...
+ QCOMPARE(splitter.layout(), &layout);
+}
+
QTEST_MAIN(tst_QSplitter)
#include "tst_qsplitter.moc"