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. QFormLayout clear
Forum Updated to NodeBB v4.3 + New Features

QFormLayout clear

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 2.6k 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.
  • E Offline
    E Offline
    elveatles
    wrote on last edited by
    #1

    How can I clear a QFormLayout?

    I have tried (Python):

    for row in reversed(xrange(self.count())):
        item = self.takeAt(row)
        item.widget().deleteLater()
    

    This looks like it is cleared visually, but rowCount() remains the same.

    1 Reply Last reply
    0
    • E Offline
      E Offline
      elveatles
      wrote on last edited by
      #2

      I think it's a bug...

      https://bugreports.qt.io/browse/QTBUG-15990

      Just annoying that it seems like no one wants to fix it.

      1 Reply Last reply
      0
      • E Offline
        E Offline
        elveatles
        wrote on last edited by
        #3

        Is there any way to create my own QFormLayout class with the option to remove rows? I've gotten pretty close so far by making a class that inherits from QVBoxLayout, then every time a row is added, I create a QHBoxLayout with a label and field in it. The only problem I'm having is having all of the fields align to the longest label.

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

          Hi,

          You can build Qt yourself and apply the patch proposed through the bug report if you're in a hurry.

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

          1 Reply Last reply
          0
          • Chris KawaC Online
            Chris KawaC Online
            Chris Kawa
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @elveatles How about a QGridLayout with 2 columns then (label and widget)? The columns would take care of proper alignment.

            E 1 Reply Last reply
            0
            • Chris KawaC Chris Kawa

              @elveatles How about a QGridLayout with 2 columns then (label and widget)? The columns would take care of proper alignment.

              E Offline
              E Offline
              elveatles
              wrote on last edited by
              #6

              @Chris-Kawa I've discovered that QGridLayout has the same issue.

              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