[Qt-interest] QSplitter behavior when widgets are removed

Ivo Anjo knuckles at gmail.com
Wed Apr 29 18:21:03 CEST 2009


I'm looking into kde bug #190265 (
https://bugs.kde.org/show_bug.cgi?id=190265) and QSplitter seems to have a
rather strange behavior when child widgets are removed.

Using this test case: (also attached)
#include <QApplication>
#include <QSplitter>
#include <QPushButton>

int main(int argc, char **argv) {
        QApplication app(argc, argv);
        QSplitter *s = new QSplitter();
        for (int i = 0; i < 2; ++i) {
                QPushButton *pb = new QPushButton("delete" +
QString::number(i));
                s->addWidget(pb);
                QObject::connect(pb, SIGNAL(clicked()), pb,
SLOT(deleteLater()));
        }
        s->show();
        return app.exec();
}

If I collapse the splitter, and then click on the remaining button, the
splitter is gone, with no way to get it back.

Also by changing the test to create, for example, 4 buttons, if you collapse
all the splitters to one of the sides, leaving you with 3 splitters on one
of the sides, and one button being shown, and you click the button, one of
splitters correctly disappears, another one jumps to somewhere around the
middle of the widget, and the remaining one stays collapsed, but none of the
buttons are shown.
Only by dragging one of the splitters do the widgets reappear, and even then
don't cover the whole QSplitter space -- you have to "push" the buttons
until they cover the full QSplitter space, and then it all starts working
normally again.

So my question is: is this a bug? Is this supposed to be like this? Does
QSplitter assume that widgets cannot be removed?

Thanks in advance,
Ivo Anjo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090429/22575d16/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qsplitter-testcase.cpp
Type: text/x-c++src
Size: 411 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090429/22575d16/attachment.bin 


More information about the Qt-interest-old mailing list