I do everything in the Qt Designer (Qt Creator 4.1.0, Based on Qt 5.6.2). For testing this, i made a very simple form with just the 3 elements (2 Qframes with a QSplitter) and everything looks fine in here (the XML/.ui file).
I made a bit of code to read out all the topLevelWidgets in of my form and dump them into a txt file to see the result. This is similar to how I use it in my application.
That code is:
{
if (depth)
const QRect geom
= w
->geometry
();
str << '"' << w->metaObject()->className() << "\"/\"" << w->objectName() << "\" "
<< geom
<< (w->isVisible() ? "[visible] " : "[hidden] ");
if (w->testAttribute(Qt::WA_Mapped))
str << "[mapped] ";
str << '\n';
foreach
(QObject *c, w
->children
()) { if (c->isWidgetType())
dumpWidgetRecursion
(str,
(const QWidget *)(c
), depth
+ 1);
}
}
static void dumpAllWidgets()
{
std::ofstream myfile("dumpallwidgets.txt");
str << "### QWidgets:\n";
dumpWidgetRecursion(str, w);
myfile << d.toStdString();
}
static void dumpWidgetRecursion(QTextStream &str, const QWidget *w, int depth = 0)
{
if (depth)
str << QString(depth * 2, QLatin1Char(' '));
const QRect geom = w->geometry();
str << '"' << w->metaObject()->className() << "\"/\"" << w->objectName() << "\" "
<< geom
<< (w->isVisible() ? "[visible] " : "[hidden] ");
if (w->testAttribute(Qt::WA_Mapped))
str << "[mapped] ";
str << '\n';
foreach (QObject *c, w->children()) {
if (c->isWidgetType())
dumpWidgetRecursion(str, (const QWidget *)(c), depth + 1);
}
}
static void dumpAllWidgets()
{
QString d;
QTextStream str(&d);
std::ofstream myfile("dumpallwidgets.txt");
str << "### QWidgets:\n";
foreach (const QWidget *w, QApplication::topLevelWidgets())
dumpWidgetRecursion(str, w);
myfile << d.toStdString();
}
To copy to clipboard, switch view to plain text mode
which gives me a result of:
"QSplitter"/"splitter" 571x241+140+70[visible]
"QFrame"/"frame_B" 571x118+0+123[visible]
"QFrame"/"frame_A" 571x118+0+0[visible]
"QSplitterHandle"/"qt_splithandle_" 100x30+0+0[hidden]
"QSplitterHandle"/"qt_splithandle_" 571x5+0+118[visible]
"QSplitter"/"splitter" 571x241+140+70[visible]
"QFrame"/"frame_B" 571x118+0+123[visible]
"QFrame"/"frame_A" 571x118+0+0[visible]
"QSplitterHandle"/"qt_splithandle_" 100x30+0+0[hidden]
"QSplitterHandle"/"qt_splithandle_" 571x5+0+118[visible]
To copy to clipboard, switch view to plain text mode
Notice how Frame_B is above Frame_A. This is causing me issues that i don't have if the splitter is not present.
Bookmarks