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. List of Widget, how to
Forum Updated to NodeBB v4.3 + New Features

List of Widget, how to

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 138 Views 1 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.
  • C Offline
    C Offline
    cebuger
    wrote on last edited by
    #1

    Hi all,
    I have a widget i want to put it on a list like this

    e705a22a-6e33-469d-9fd9-b15e8a05cffd-image.png
    the widget is enclosed in a scrollarea so when the number exceeds the view scroll bar come out,
    I programatically add the widgets with align top

     SomeWidget* widget1 = new SomeWidget(this);
     ui->itemList->addWidget(widget1, 0, Qt::AlignTop);
    

    the problem is, if there are only like two or even a single item, QT Layout will add this in the center or will auto resize the item to fit the view like this.

    86cddf35-9cdb-4350-844b-d15d97071785-image.png

    or if two items
    ebe3d149-7fc5-4560-875e-76af1897e97a-image.png

    what i did is I created a vertical layout and just add the widget dynamically and it works as expected When there are like a good number of list.

    I want to just put the widgets after each other like a list.
    How can i do that?

    1 Reply Last reply
    1
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Add a vertical expanding spacer at the end.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      3
      • C Offline
        C Offline
        cebuger
        wrote on last edited by
        #3

        perfect thanks!

        Pablo J. RoginaP 1 Reply Last reply
        0
        • C cebuger

          perfect thanks!

          Pablo J. RoginaP Offline
          Pablo J. RoginaP Offline
          Pablo J. Rogina
          wrote on last edited by
          #4

          @cebuger said in List of Widget, how to:

          perfect thanks!

          Did it work?
          If so please don't forget to mark your post as solved!

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          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