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. [SOLVED] scrollArea in scrollArea
Forum Update on Tuesday, May 27th 2025

[SOLVED] scrollArea in scrollArea

Scheduled Pinned Locked Moved General and Desktop
qscrollbarqscrollarea
5 Posts 2 Posters 1.7k Views 2 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 A Former User
    #1

    Hi all!

    I m have class of the category with fixed height
    it's two labels, one scroll area and button "show\hide scroll area" plased with layout

    when i added to the scrollarea some widgets - the scrollarea blow up self height despite the height of category, respectively widgets show incorrect and gone out the border

    why the layout does not interfere?
    why setMaximumHeight on the scrollarea doesn't work?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @MEPTPAH said:

      when i added to the scrollarea some widgets

      Should you not add it to the layout object and not the scrollarea ?

      Maybe you do.

      Its hard to give suggestions with no code/pictures.

      ? 1 Reply Last reply
      0
      • mrjjM mrjj

        @MEPTPAH said:

        when i added to the scrollarea some widgets

        Should you not add it to the layout object and not the scrollarea ?

        Maybe you do.

        Its hard to give suggestions with no code/pictures.

        ? Offline
        ? Offline
        A Former User
        wrote on last edited by A Former User
        #3

        @mrjj

        ...hope without code...

        void categoryWidget::_initScrollArea()
        {
        _scrollArea = new QScrollArea;
        _scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
        _scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
        _scrollAreaLayout = new QVBoxLayout(_scrollArea);
        _scrollAreaLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
        layout()->addWidget(_scrollArea);
        }

        after i am adding widgets (they can be like this), and now scroll area increas self height ignoring size of the parent where she is placed

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

          solved:

          adding widget layer

          void categoryWidget::_initScrollArea()
          {
          _scrollArea = new QScrollArea;
          _scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
          _scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
          QWidget* _scrollAreaLayer = new QWidget;
          _scrollArea->setWidget(_scrollAreaLayer);
          _scrollAreaLayout = new QVBoxLayout(_scrollAreaLayer);
          _scrollAreaLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
          layout()->addWidget(_scrollArea);
          }

          Then scroll bar appears as need

          1 Reply Last reply
          0
          • ? A Former User

            @mrjj

            ...hope without code...

            void categoryWidget::_initScrollArea()
            {
            _scrollArea = new QScrollArea;
            _scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
            _scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
            _scrollAreaLayout = new QVBoxLayout(_scrollArea);
            _scrollAreaLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
            layout()->addWidget(_scrollArea);
            }

            after i am adding widgets (they can be like this), and now scroll area increas self height ignoring size of the parent where she is placed

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by mrjj
            #5

            ah. the _scrollAreaLayer does respect the size limits then. Good to know.

            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