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. Unexpected behavior when hiding and showing widgets in a layout
Forum Updated to NodeBB v4.3 + New Features

Unexpected behavior when hiding and showing widgets in a layout

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 3.1k 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.
  • J Offline
    J Offline
    JulienMaille
    wrote on last edited by
    #1

    Dear Qt users:
    I have two identical widgets in an horizontal layout and I added buttons that allows showing and hiding them.
    Before I added this buttons, my widgets used to always have the same size.
    Now I have a strange issue, when I hide and reshow one widget, I don't get a 50%-50% width but something like 30-70%.

    Do I need to call something on the parent layout, right after changing the visibility status of the widgets?
    !http://pix.wefrag.com/i/b/7/e/d/b/44501b9c2364b5cb4f169c594def2d16.png(example)!

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dangelog
      wrote on last edited by
      #2

      That's ... interesting. Do you have a testcase? Sounds like a bug.

      Software Engineer
      KDAB (UK) Ltd., a KDAB Group company

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JulienMaille
        wrote on last edited by
        #3

        I currently can't share my code but I can set up an empty project and try to reproduce the issue.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          Did you try to set a stretch factor of 1 on both layout elements?
          Does the size hint always return the same value?
          What are the size policies?

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • J Offline
            J Offline
            JulienMaille
            wrote on last edited by
            #5

            When I set a stretch factor of 1, the remaining widget does not expand in the empty space leaved by the hidden one.
            Size policies are MinimumExpanding for both widgets and the layoutSizeConstraint of the parent layout is set to SetMaximumSize

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on last edited by
              #6

              Hm, strange. The small test project would be really helpful now :)

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • J Offline
                J Offline
                JulienMaille
                wrote on last edited by
                #7

                I'm now hiding elements like this:
                @ for( int i=0; i< ui->resultLayout->count(); ++i )
                ui->resultLayout->itemAt(i)->widget()->setVisible(false);
                @
                and it works like expected. I will update this thread if I have any new 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