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. Hide widget if parent window width <widget.width ?

Hide widget if parent window width <widget.width ?

Scheduled Pinned Locked Moved Solved General and Desktop
qwidgetqlayoutqsizepolicy
5 Posts 2 Posters 968 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.
  • D Offline
    D Offline
    Dariusz
    wrote on 11 Nov 2019, 18:40 last edited by
    #1

    Hey

    I'd like to hide a widget if the parent widget/window/other widget width is below a certain point. I have some "useless" labels that I'd like to hide to allow for more comfortable work.

    Does QT offer anything like that

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 11 Nov 2019, 18:46 last edited by
      #2

      Hi,

      Something like QSplitter ?

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

      D 1 Reply Last reply 11 Nov 2019, 18:56
      0
      • S SGaist
        11 Nov 2019, 18:46

        Hi,

        Something like QSplitter ?

        D Offline
        D Offline
        Dariusz
        wrote on 11 Nov 2019, 18:56 last edited by
        #3

        @SGaist said in Hide widget if parent window width <widget.width ?:

        Hi,

        Something like QSplitter ?

        I don't want to manually hide the widget. Just automatically hide when empty space runs out.

        Say I have window that is 400 wide and 4 widgets that take 200 pixels. if window.width()<200, then one of the 4 widgets should disappear and the remaining 3 become wider to show data better. I suppose all widgets with flag to auto-hide should disappear at once... mhmhmmm Something tells me Qt does not have it o.O

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 11 Nov 2019, 20:18 last edited by
          #4

          AFAIK, no it does not. However one thing that is sure is that you should handle that in the widget containing those that should be made invisible and not the other way around.

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

          D 1 Reply Last reply 11 Nov 2019, 21:34
          0
          • S SGaist
            11 Nov 2019, 20:18

            AFAIK, no it does not. However one thing that is sure is that you should handle that in the widget containing those that should be made invisible and not the other way around.

            D Offline
            D Offline
            Dariusz
            wrote on 11 Nov 2019, 21:34 last edited by
            #5

            @SGaist I ended up hocking up to resize event of parent widget to find out when size changed & resize my other widget acordingly.

            I ended up using "invisible" QLabel that retains size as my "spacer". I had to change its spacing role on the go depending of one or more widget are visible or not as I needed to retain correct order. So far works great.

            TIA

            1 Reply Last reply
            0

            1/5

            11 Nov 2019, 18:40

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved