Important: Please read the Qt Code of Conduct -

QScrollArea, QTabWidget, .ui form opened in MainWindow

  • hi,

    just to continue my previous thread from "here":

    after I inserted the .ui form in the TabWidget, I would like to have the form scrollable, meaning if the
    MainWindog is resized to have the scroll bars available on the bottom and right side.

    for this i tried to implement in my form addA.cpp the following code:

    @#include <QScrollArea>
    #include <QMainWindow>

    addA::addA(QWidget *parent) :
    ui(new Ui::addA)

    QScrollArea * scrollArea = new QScrollArea();

    this code didn't work to make my addA.ui form scrollable.

    than i tried in my mainwindow.cpp the following code:

    @QTabWidget *tabWidget = new QTabWidget;
    addA *nA = new addA();
    tabWidget->addTab (nA, tr("Test"));
    QScrollArea * scrollArea = new QScrollArea();

    what i'm doing wrong?

  • hi,

    I was looking in Qt Creator Help manual installed on machine, local, and under User Guide, FAQ, i found the following statement:

    "Why does Qt Creator not use tabs for editors?

    This question comes up from time to time, so we have considered it carefully. Here are our main reasons for not using tabs:

    • Tabs do not scale. They work fine if you have 5 to 6 editors open, they become cumbersome with 10, and if you need more horizontal space than the tab bar, the interface does not work at all.
    • Tabs do not adapt to your working set.
    • The common solution is to give the user the ability to reorder tabs. Now user has to manage tabs instead of writing code.
    • Tabs force you to limit the amount of open editors, because otherwise you get confused."

    I have one misunderstandings:

    1. "* Tabs do not scale. " does this means that as soon as I use QTabWidget in my mainwindow and i would like to change the size of the window from maximized to any custom size, my QTabWidget will not scale? meaning my window can't be scrollable? meaning I shouldn't expect to have a ScrollArea on QTabWidgets?

    where could I find more details about these issues? the QTabWidget class details doesn't specify anything.

    thank for your input.

Log in to reply