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 Monday, May 27th 2025

[SOLVED] scrollArea in scrollArea

Scheduled Pinned Locked Moved General and Desktop
qscrollbarqscrollarea
5 Posts 2 Posters 1.7k Views
  • 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 13 Jul 2015, 12:40 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
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 13 Jul 2015, 12:54 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 13 Jul 2015, 13:12
      0
      • M mrjj
        13 Jul 2015, 12:54

        @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 13 Jul 2015, 13:12 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

        M 1 Reply Last reply 13 Jul 2015, 13:24
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on 13 Jul 2015, 13:22 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
            13 Jul 2015, 13:12

            @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

            M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 13 Jul 2015, 13:24 last edited by mrjj
            #5

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

            1 Reply Last reply
            0

            1/5

            13 Jul 2015, 12:40

            • Login

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