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. QTabWidget not reduced
Qt 6.11 is out! See what's new in the release blog

QTabWidget not reduced

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 2.2k Views 1 Watching
  • 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      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...

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        [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();
        }
        @

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            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).

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              even using e.g. setFixedSize ?

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

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                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);@

                1 Reply Last reply
                0

                • Login

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