0

The thing I'm going for is basically a panel that holds three items, with the middle one having the size of the screen (here a QScrollArea). The point is that I then shift the QScrollArea to reveal the left and right items as needed, like illustrated below.

Example GUI

Here, the left and right tabs are supposed to be hidden, with the text edit in the middle taking up the entirety of the scroll area (scroll bars are hidden here). Clicking the buttons labeled "Structure" and "Options" on the left and right should scroll said scroll area and reveal the corresponding tab. The Qt Designer structure is as follows :

Qt Designer structure

mrte_text is my own custom class for the WYSIWYG widget. Both tabs are ad-hoc widgets created for the occasion that I am adding in MainWindow::show with the following code :

void MainWindow::show()
{
    QHBoxLayout *l = (QHBoxLayout*)ui->scrollAreaWidgetContents->layout();
    QMainWindow::show();
    l->insertWidget(0, searchTab);
    l->insertWidget(2, chatTab);
    baseX = ui->scrollAreaWidgetContents->x();
    baseY = ui->scrollAreaWidgetContents->y();
    searchTab->move(baseX - searchTab->width(), baseY);
    chatTab->move(baseX + ui->mrte_text->width(), baseY);
}

Moving the tabs don't seem to do anything, as removing the move lines changes nothing, but I have explored this possibility.

Matrefeytontias
  • 592
  • 1
  • 4
  • 13
  • Maybe this is related https://stackoverflow.com/questions/18394706/show-hide-sub-tab-on-qtabwidget?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa ? – user2672165 Apr 10 '18 at 20:28
  • I don't think this works. The tabs in the thread you linked are actual tabs in the sense of Qt, and also I don't want to hide my widgets, because making them visible again will resize the layout to fit everything in the visible part of the scroll area, when I really just want to scroll it. – Matrefeytontias Apr 10 '18 at 20:34

1 Answers1

1

Looks like something you could handle with QSplitter

On an unrelated note, you shouldn't use show to do that kind of setup. That method is not only called the first time the widget is shown.

SGaist
  • 906
  • 8
  • 33
  • 109