Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

    Resize QScrollArea to fit content

    General and Desktop
    1
    2
    5516
    Loading More Posts
    • 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.
    • S
      strangelookingnerd last edited by

      Hello!

      I got a QWidget inside a QScrollArea (see below)

      @void Ui_Manager::setupUi(QWidget *manager)
      {
      QScrollArea *scrollArea = new QScrollArea();
      scrollArea->setWidget(manager);
      scrollArea->setWidgetResizable(true);
      }@

      During Runtime i add several other Widgets to the Manager and move them into free space available inside the Manager-Widget:

      @void addWidgets(QWidget *ptr, QPoint pos)
      {
      ptr->setParent(this);
      ptr->move(pos);
      ptr->show();
      }@

      So it may happen, that the added Widgets were moved outside of the visible region of the Manager when there is not enough space available - thats the point where i hoped for the ScrollArea to take control and give me some nice ScrollBars to access the "hidden" Widgets. But it won't show me any ScrollBars and i don't have any idea why or how to change this.
      This problem bothers me for a while now and i hope for someone here to give me a little hint :)

      Thanks!

      1 Reply Last reply Reply Quote 0
      • S
        strangelookingnerd last edited by

        Addition:

        Just tried to add a Layout to the Manager and added the widgets to the Layout which made the Scrollbar work like a charm. But i can't use a Layout bcs I'm using drag&drop to move the added Widgets and using a Layout would overwrite positions of the widgets when the Manager-Window is resized.
        This makes me even more confused :/

        Someone help me fix this please!

        1 Reply Last reply Reply Quote 0
        • First post
          Last post