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. How to make the ScrollAreaWidgetContents to be adaptive
Qt 6.11 is out! See what's new in the release blog

How to make the ScrollAreaWidgetContents to be adaptive

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 1.9k 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.
  • MihanM Offline
    MihanM Offline
    Mihan
    wrote on last edited by
    #1

    I want to make the size of the scrollAreaWidgetContents can be adaptive so that the QScrollArea can choose whether to display the scroll bar based on the content inside ( e.g. QToolBox, I don't want to display the scroll bar in QToolBox but in QScrollArea).

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

      Hi,

      Can you describe more precisely what kind of widget you are currently building ?

      In any case, are you looking for the widgetResizable property ?

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

      MihanM 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        Can you describe more precisely what kind of widget you are currently building ?

        In any case, are you looking for the widgetResizable property ?

        MihanM Offline
        MihanM Offline
        Mihan
        wrote on last edited by
        #3

        Thanks @SGaist .
        Now there is a limited window and I want to show a member list in there by QToolBox. So I use QScrollArea and put the 'QToolBox' in it. Now I want the scroll bar adaptived (value and vision ) when one item in QToolBox was opened and the window can't display all the contens, not need me to set the size of scrollAreaWidgetContents bigger than QScrollArea in advance and the scrollBar's value is fixed.
        the widgetResizable() is true , what should I do.

        1 Reply Last reply
        0
        • A.A.SEZENA Offline
          A.A.SEZENA Offline
          A.A.SEZEN
          wrote on last edited by A.A.SEZEN
          #4

          Hi,
          i used it like this.
          According to the status of the chartView scrollArea is or not.
          on header file.
          QChartView * chartView;
          QScrollArea * scroll;

          on cpp file
          chartView = new QChartView();
          scroll = new QScrollArea;
          scroll->setWidget(chartView);
          ui->frame->layout()->addWidget(scroll);
          scroll->setStyleSheet("background-color:transparent;");

          MihanM 1 Reply Last reply
          0
          • A.A.SEZENA A.A.SEZEN

            Hi,
            i used it like this.
            According to the status of the chartView scrollArea is or not.
            on header file.
            QChartView * chartView;
            QScrollArea * scroll;

            on cpp file
            chartView = new QChartView();
            scroll = new QScrollArea;
            scroll->setWidget(chartView);
            ui->frame->layout()->addWidget(scroll);
            scroll->setStyleSheet("background-color:transparent;");

            MihanM Offline
            MihanM Offline
            Mihan
            wrote on last edited by Mihan
            #5

            Thanks @A-A-SEZEN
            I will try donig that on cpp later,.
            Now I just do that on designer, cus I can promote the widget easily.

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

              I don't understand why you want to put your QToolBox in a QScrollArea. AFAIR, it already handles large content itself showing scroll bars as needed.

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

              MihanM 1 Reply Last reply
              1
              • SGaistS SGaist

                I don't understand why you want to put your QToolBox in a QScrollArea. AFAIR, it already handles large content itself showing scroll bars as needed.

                MihanM Offline
                MihanM Offline
                Mihan
                wrote on last edited by
                #7

                @SGaist
                Cus I want the scroll bar is a total scroll bar, not the scroll bar of each widget in QToolbox. I think it is a bit unattractive and out of line with user habits.
                Sorry maybe my request is a bit harsh. If it can not achieve this effect, I can make it with buttons and widget in a scroll area, just a bit complicated.
                Thank you~

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

                  Can you show an example of the visual you are trying to produce ?

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

                  MihanM 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Can you show an example of the visual you are trying to produce ?

                    MihanM Offline
                    MihanM Offline
                    Mihan
                    wrote on last edited by Mihan
                    #9

                    Hi @SGaist
                    I make a simple picture to show what I want. Each widget in toolbox can show all contents without blank and scrollbar. And if the entire toolbox is out of display in mainwindows(has a scrollarea), it will show the scrollbar (outside the toolbox).
                    I have read the source code of QToolBox, there is a QScrollArea in struct Page. I think we can add an attribute about how to show the contents in each page to let designers choose it, and remind the designers make sure the minimum size of each widget in each page. when one tab is clicked, the toolbox will be resized.
                    I hope and suggest this attribute will be used in new Qt version, cus I think it is more appropriate.
                    CustomToolBox.png
                    Also thanks @mrjj in here.
                    Regards.
                    Mihan

                    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