I have parent widget and two child widgets in it (most likely I will put them in QSplitter). I want to display their names to clearly define where stuff is. Preferably in a frame at the top of the widget, like it's an embedded window.
How to do that in Qt?
Here's a way to achieve that:
QMainWindow
.QSplitter
.QMainWindow
s to the splitter.QToolBar
s to the sub main windows:
Example:
#include <QApplication>
#include <QtWidgets>
int main(int argc,char*argv[])
{
QApplication a(argc, argv);
QMainWindow ww;
ww.addToolBar("Main ToolBar");
QSplitter *s = new QSplitter(Qt::Horizontal,&ww);
ww.setCentralWidget(s);
QMainWindow *left = new QMainWindow(&ww);
QToolBar *t = new QToolBar("Left Toolbar");
t->setMovable(false);
t->addWidget(new QLabel("ChildWidget 1"));
left->addToolBar(t);
left->addToolBarBreak();
left->addToolBar("Left tool bar");
QMainWindow *right = new QMainWindow(&ww);
QToolBar *t1 = new QToolBar("Right Toolbar");
t1->setMovable(false);
t1->addWidget(new QLabel("ChildWidget 2"));
right->addToolBar(t1);
right->addToolBarBreak();
right->addToolBar("Right tool bar");
s->addWidget(left);
s->addWidget(right);
ww.show();
return a.exec();
}
Result: