Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. I hope the check box is aligned from the top. What should I do?
Forum Updated to NodeBB v4.3 + New Features

I hope the check box is aligned from the top. What should I do?

Scheduled Pinned Locked Moved Unsolved Qt for Python
5 Posts 2 Posters 539 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.
  • R Offline
    R Offline
    Radell
    wrote on last edited by
    #1

    I use pyqt5. I make verticalLayout.addWidget(checkBox)
    center.PNG
    It's not the result I expected. It's concentrated in the center, so I hope it comes out in order from the top
    change self.fileLayout.addWidget(cb) -> self.fileLayout.addWidget(cb, alignment=Qt.AlignTop)
    result... gap between the check boxes is too wide. What should I do? very sad..
    after.PNG

    JonBJ 1 Reply Last reply
    0
    • R Radell

      I use pyqt5. I make verticalLayout.addWidget(checkBox)
      center.PNG
      It's not the result I expected. It's concentrated in the center, so I hope it comes out in order from the top
      change self.fileLayout.addWidget(cb) -> self.fileLayout.addWidget(cb, alignment=Qt.AlignTop)
      result... gap between the check boxes is too wide. What should I do? very sad..
      after.PNG

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Radell
      Well, since you already discovered that self.fileLayout.addWidget(cb, alignment=Qt.AlignTop) moved the first checkbox to the top, why wouldn't you do that to the second checkbox too?

      IIRC, the way to make all widgets move to the top is by QBoxLayout::addStretch(int stretch = 0) to add a stretch after your checkboxes. That then "stretches" as much as possible, filling the whole of the bottom area.

      JonBJ 1 Reply Last reply
      2
      • R Offline
        R Offline
        Radell
        wrote on last edited by
        #3

        @JonB
        I applied it to all the boxes. but There's a gap that didn't exist in the center alignment.

        1 Reply Last reply
        0
        • JonBJ JonB

          @Radell
          Well, since you already discovered that self.fileLayout.addWidget(cb, alignment=Qt.AlignTop) moved the first checkbox to the top, why wouldn't you do that to the second checkbox too?

          IIRC, the way to make all widgets move to the top is by QBoxLayout::addStretch(int stretch = 0) to add a stretch after your checkboxes. That then "stretches" as much as possible, filling the whole of the bottom area.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @JonB said in I hope the check box is aligned from the top. What should I do?:

          IIRC, the way to make all widgets move to the top is by QBoxLayout::addStretch(int stretch = 0) to add a stretch after your checkboxes. That then "stretches" as much as possible, filling the whole of the bottom area.

          Did you do this? (This means one stretch after the last checkbox.)

          R 1 Reply Last reply
          0
          • JonBJ JonB

            @JonB said in I hope the check box is aligned from the top. What should I do?:

            IIRC, the way to make all widgets move to the top is by QBoxLayout::addStretch(int stretch = 0) to add a stretch after your checkboxes. That then "stretches" as much as possible, filling the whole of the bottom area.

            Did you do this? (This means one stretch after the last checkbox.)

            R Offline
            R Offline
            Radell
            wrote on last edited by
            #5

            @JonB
            Your advice was the best!!!
            thanks :)

            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