Qt Forum

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

    Call for Presentations - Qt World Summit

    Management of many QGroupBox in a single QVBoxLayout

    General and Desktop
    2
    4
    941
    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.
    • K
      kloveridge last edited by

      I am designing a GUI where the user will select a tree node. Depending on the type of node they select, I have a QVBoxLayout that will show a QGroupBox with various attributes that can be set for the node.

      My question is, there are many different node types. Each will need to reconfigure the QVBoxLayout. My initial take on how to do this is load the QVBoxLayout with every node QGroupBox and just regulate what appears in the layout using the visibility state.

      Is this a viable solution? Or would it be better to tear down the QVBoxLayuout and only make it contain what QGroupBox layout it needs for a given node? Any advice?

      1 Reply Last reply Reply Quote 0
      • Chris Kawa
        Chris Kawa Moderators last edited by

        The answer is as usual: it depends.

        One aspect here is the number of boxes. If it's a couple then it might be ok to keep them around hidden. If there are 50 of them it might be better to dynamically create/destroy them.
        Of course another aspect is how complicated the boxes are. If they are complex you might not want to wait for building them every time you select a node. If they're simple it might be ok.

        I'd say measure, check and profile.

        1 Reply Last reply Reply Quote 0
        • K
          kloveridge last edited by

          There probably will be 25-30 boxes. Some will be simple. Some will be complex.

          Can I just allocate them all on startup and just add/remove them from QVBoxLayout as selection changes? So instead of hide/show mechanism. I do a remove/add.

          Maybe its probably not a big deal to completely destroy them and reallocate them. I have a aversion to deleting items I know will be used frequently.

          1 Reply Last reply Reply Quote 0
          • Chris Kawa
            Chris Kawa Moderators last edited by

            I can't tell you what's right for you. All mentioned solutions will do the job. Some are just better suited for one or another scenario.

            Do it and see how it works. If it works for your scenario then it works ;)

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