QTabWidget not reduced



  • Hi, everyone!
    I have a QTabWidget in my project with several tabs.
    On the first tab there is only one small widget. On the second tab I've many other widget's and when I picked up this tab all my window grew to a suitable size. After that I picked up the first tab but the size didn't change even I couldn't do it by hand.
    (I added a scroll to solve this problem temporarily. Because on the second tab too many widgets that made the app bigger than my display)

    Now I want to find a way to make this widget resizable!
    It would be nice if the widget reduced size to a suitable size.
    I tried to use "sizePolicy", but nothing changed



  • H and welcome to DevNet.

    In fact, a widget always grows untill all needed widgets fit. If you have a tab, it might be, that the widgets gets bigger on displaying a tab. It wioll grow to the minimum size of the tab. If you switch away again, the new minimum size stays.

    So maybe you can play with minimumSize, but that might result in a funny second tab...



  • [quote author="Gerolf" date="1413802755"]H and welcome to DevNet.

    In fact, a widget always grows untill all needed widgets fit. If you have a tab, it might be, that the widgets gets bigger on displaying a tab. It wioll grow to the minimum size of the tab. If you switch away again, the new minimum size stays.

    So maybe you can play with minimumSize, but that might result in a funny second tab...[/quote]

    thanks, Gerolf.
    I set connection between Tab's SIGNAL and my slot where I set up minimumSize (0,0) but nothing changed.
    @
    QObject::connect(mainTab,SIGNAL(currentChanged(int)),this,SLOT(resizeMainTab()));

    void MainWindow::resizeMainTab()
    {
    mainTab->setMinimumSize(0,0);
    mainTab->update();
    }
    @


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    setMinimumsize(0, 0) won't do anything special you are just telling your mainTab that it's smallest size is 0, 0. You should rather resize it based on the current widget sizeHint



  • Thanks, SGaist
    I tried to play with different widget's sizes. But mb I can't fix it because my Layout have SetFixedSize.. (It's needed me for correct displaying)

    one more question then.. I'm trying to put my Tab's in QScrollArea, but then I have one more Frame around my widgets and grey background. How can I make it invisible. I just want ScrollBar appears when he is needed (without frame).


  • Lifetime Qt Champion

    even using e.g. setFixedSize ?

    Do you mean -> QTabWidget -> QScrollArea -> Your Tab Widget ?



  • 1)This layout have Fixed size. It's one of lists in a TabWidget. When I add here many big widgets it grows. I go to another List and this list has the same size even it's empty, And I can't reduce the size of empty List by hand. I tried to do it in code using setMinimumSize, sizeHint... But the TabWidget has Fixed size.
    @layoutATabL->setSizeConstraint(QLayout::SetFixedSize);@

    2)Well... Then I added a ScrollArea. But now I have a grey frame around my widgets. scrollAreaWidgetContents makes this Frame, I think so. But How can I make it invisible.
    @
    listTabA = new QTabWidget(tabA);
    listTabA->setObjectName(QString::fromUtf8("listTabA"));
    layoutATab->addWidget(listTabA,0,0,1,1);
    tabAL1 = new QWidget(listTabA);
    tabAL1->setObjectName(QString::fromUtf8("tabAL1"));
    listTabA->addTab(tabAL1,QString::fromUtf16(L"Ком 1"));

    QGridLayout *gridLayout = new QGridLayout(tabAL1);
    gridLayout->setSpacing(3);
    gridLayout->setContentsMargins(6,6,6,6);
    gridLayout->setObjectName(QString::fromUtf8("gridLayout1"));

    //-------------------------
    QScrollArea *scrollArea = new QScrollArea(mainTab);
    scrollArea->setObjectName(QString::fromUtf8("scrollArea"));
    scrollArea->setWidgetResizable(true);
    QWidget *scrollAreaWidgetContents = new QWidget(scrollArea);
    scrollAreaWidgetContents->setObjectName(QString::fromUtf8("scrollAreaWidgetContents"));

    layoutATabL = new QGridLayout(scrollAreaWidgetContents);
    layoutATabL->setSpacing(3);
    layoutATabL->setContentsMargins(11,11,11,11);
    layoutATabL->setObjectName(QString::fromUtf8("layoutAL1"));
    layoutATabL->setSizeConstraint(QLayout::SetFixedSize);

    scrollArea->setWidget(scrollAreaWidgetContents);
    //-------------------------
    gridLayout->addWidget(scrollArea);@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.