Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Widget above widget (searchBox)
Forum Updated to NodeBB v4.3 + New Features

Widget above widget (searchBox)

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 133 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AndrzejB
    wrote on last edited by
    #1

    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?

    JonBJ 1 Reply Last reply
    0
    • A AndrzejB

      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?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @AndrzejB
      I believe you are asking here how to place one widget on top of another widget, right? Then I would Google for qt 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.

      1 Reply Last reply
      0
      • A AndrzejB has marked this topic as solved on

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved