Qt Forum

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

    Call for Presentations - Qt World Summit

    Dynamic forms

    General and Desktop
    3
    4
    3773
    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.
    • M
      mirswith last edited by

      What is the best way to change the items in a QFormLayout dynamically? I was hoping for a simple visible property but that does not seem to exist. I then tried creating two QFormLayout objects and put my common controls in one and the ones I want to conditionally hide in the other however this has some strange behavior. The first is that my columns will not line up (for obvious reasons) but the other one is that when I remove the non-common layout I still see the first row and then my common params are overlayed on top of that, I assume I am doing something wrong.

      This is how I am adding the form layouts (note this is in the initializePage of a Wizard I am working on):

      @
      layout()->removeItem(_master);
      layout()->removeItem(_common);
      if( someCondition )
      {
      layout()->addItem(_master);
      }
      layout()->addItem(_common);
      @

      Ideally though, even if this works I would prefer to use a single QFormLayout so my column widths remain consistent.

      Thanks.

      1 Reply Last reply Reply Quote 0
      • A
        andre last edited by

        Could you perhaps post a drawing or something like that of what you want to achieve?

        1 Reply Last reply Reply Quote 0
        • M
          mirswith last edited by

          For examples sake lets say I wanted to present a form to a user that captures there name and gender, then when a user clicked they were male or female I would then add some fields specific for that gender (in this case maybe its a health ins. form or something).

          In my case I am doing this with a wizard and know from the previous page what fields I want to display, a couple of them are common regardless of the previous page but then the others are not. I could probably recreate the form everytime in the initializePage function, I however have been trying to create all the controls in the constructor then modifying the layout in initializePage.

          1 Reply Last reply Reply Quote 0
          • E
            Eddy last edited by

            Have a look in the offical Qt book." You can download it here":http://www.qtrac.eu/C++-GUI-Programming-with-Qt-4-1st-ed.zip
            In one of the first chapters they explain how to do something like what you want with example code..

            Qt Certified Specialist
            www.edalsolutions.be

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