Widget above widget (searchBox)
-
I want make search ability in my editor. If I press control+F appears widget with string to search.
Now I have QVBoxLayout with searchBar and editor and searchBar can be visible or non visible:plainEdit = new PlainTextEdit(this); sideBar = new CodeEditorSidebar(this); searchBar = new SearchBar(this); auto *vLayout = new QVBoxLayout; auto *hLayout = new QHBoxLayout; vLayout->setContentsMargins(0,0,0,0); vLayout->setSpacing(0); hLayout->setContentsMargins(0,0,0,0); hLayout->setSpacing(0); hLayout->addWidget(sideBar); hLayout->addWidget(plainEdit); searchBar->hide(); vLayout->addWidget(searchBar); vLayout->addLayout(hLayout); setLayout(vLayout);
It has small disadvantage: if sideBar appears, editor moves down (2D down), because now are visible two elements: sideBar and editor. I prefer : sidebar appears above (3D above) editor and partially obscures editor. I have tried QStackedLayout but editor was invisible.
How do it? -
@AndrzejB
I believe you are asking here how to place one widget on top of another widget, right? Then I would Google forqt widget on top of widget
. https://stackoverflow.com/questions/28147360/qt-widget-displayed-over-other-widgets is one such hit, though I don't know if there are better ones. I think you don't want to place the two widgets on a layout because that will adjust them to not overlap.Someone else may have a better answer.
-