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. QScrollArea issues
QtWS25 Last Chance

QScrollArea issues

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.9k 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.
  • B Offline
    B Offline
    bamboo
    wrote on last edited by
    #1

    Hey everyone,

    I've been pulling my hair out over the QScrollArea for the past couple of days. What I want to do is this: I want to make an area on my window which will contain a variable number of rows of lineEdit and pushButton widgets. They are laid out in a gridLayout which I have put in a frame. That frame is put into a scrollArea so that when more rows are added, they scan be scrolled to.

    I have had zero success using QtDesigner. I drag the scrollArea to the window, drag the frame to the scrollArea and then the gridLayout to the frame but when running, there are no scroll bars.

    I have had some success programming it by hand.

    @
    scrollArea = new QScrollArea(tab_2);
    fra_ds_segments = new QFrame;
    gridLayout_2 = new QGridLayout(fra_ds_segments);

    fra_ds_segments->setLayout(gridLayout_2);
    scrollArea->setWidget(fra_ds_segments);

    scrollArea->setGeometry(10, 210, 855, 201);

    <<add lines of lineEdits and pushButtons to gridLayout_2>>

    fra_ds_segments->resize(gridLayout_2->sizeHint());
    @

    This seems to work OK though I'd rather calculate the size of scrollArea rather than hard-code it. I have hard-coded it to an area which doesn't need vertical scroll bars for 5 lines but will for any more than that. So as an aside, does anyone know how to calculate the proper width of a scrollArea to hold certain items an not need scroll bars?

    The main issue is...how can I use a scrollArea this way within Designer?

    Thanks!

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tim.sullivan
      wrote on last edited by
      #2

      Any progress with this? I'm having the same issue.
      My situation also requires that the contents of the scroll area change dynamically. After a button push, widgets are supposed to be added to one of two groupboxes inside the scroll area. I believe I'm taking a fairly typical approach with Qt Designer:

      • Add Scroll Area to main widget.
      • Drop groupboxes inside ScrollAreaContents (created automatically by Qt Designer when placing ScrollArea)
      • Set Scroll Area layout with "Lay Out">"Lay Out Vertically"
      • Set main widget layout likewise

      Thanks

      1 Reply Last reply
      0
      • R Offline
        R Offline
        raaghuu
        wrote on last edited by
        #3

        Have you tried "this":http://qt-project.org/doc/qt-5.0/qscrollarea.html#widgetResizable-prop ?

        1 Reply Last reply
        0
        • B Offline
          B Offline
          bamboo
          wrote on last edited by
          #4

          Hi,

          I actually ended up giving up and went on to using a QTableView instead. It worked out better for me. Good luck.

          [quote author="tim.sullivan" date="1344881283"]Any progress with this? I'm having the same issue.
          My situation also requires that the contents of the scroll area change dynamically. After a button push, widgets are supposed to be added to one of two groupboxes inside the scroll area. I believe I'm taking a fairly typical approach with Qt Designer:

          • Add Scroll Area to main widget.
          • Drop groupboxes inside ScrollAreaContents (created automatically by Qt Designer when placing ScrollArea)
          • Set Scroll Area layout with "Lay Out">"Lay Out Vertically"
          • Set main widget layout likewise

          Thanks
          [/quote]

          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