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. How can I get a child widget to resize its parent ?
Forum Updated to NodeBB v4.3 + New Features

How can I get a child widget to resize its parent ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 694 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.
  • M Offline
    M Offline
    MPFJ
    wrote on 7 Jun 2019, 20:37 last edited by
    #1

    I have a (seemingly) simple problem that I'm struggling to solve.

    I want to have a (fixed size) image widget and a (variable length, single line) label widget inside a frame widget ... so far, so good.

    But when I change the text of the label widget, I would like the parent frame to resize (up to a maximum) to accommodate the bigger / smaller label widget.

    For the parent "frame" I've tried frame, grid, hbox ... none of which seem to do what I want.

    If I have the label on its own (not as a child widget), it resizes as expected.

    Can anyone tell me how (if at all) this can be achieved ?

    Needless to say, I'm quite new to Qt, so I may be overlooking something trivial :)

    Cheers
    Mark J.

    J 1 Reply Last reply 7 Jun 2019, 21:18
    0
    • M MPFJ
      7 Jun 2019, 20:37

      I have a (seemingly) simple problem that I'm struggling to solve.

      I want to have a (fixed size) image widget and a (variable length, single line) label widget inside a frame widget ... so far, so good.

      But when I change the text of the label widget, I would like the parent frame to resize (up to a maximum) to accommodate the bigger / smaller label widget.

      For the parent "frame" I've tried frame, grid, hbox ... none of which seem to do what I want.

      If I have the label on its own (not as a child widget), it resizes as expected.

      Can anyone tell me how (if at all) this can be achieved ?

      Needless to say, I'm quite new to Qt, so I may be overlooking something trivial :)

      Cheers
      Mark J.

      J Offline
      J Offline
      JonB
      wrote on 7 Jun 2019, 21:18 last edited by JonB 6 Jul 2019, 21:19
      #2

      @MPFJ
      When you say you've tried stuff with widgets, have you been using layouts (https://doc.qt.io/qt-5/layout.html, QLayouts)? Some people try to use multiple widgets without layouts.

      M 1 Reply Last reply 7 Jun 2019, 21:55
      0
      • J JonB
        7 Jun 2019, 21:18

        @MPFJ
        When you say you've tried stuff with widgets, have you been using layouts (https://doc.qt.io/qt-5/layout.html, QLayouts)? Some people try to use multiple widgets without layouts.

        M Offline
        M Offline
        MPFJ
        wrote on 7 Jun 2019, 21:55 last edited by
        #3

        @JonB Yes.

        In the form designer, I made a grid layout with label child.

        Resizing the grid layout, resizes the label, no problem.

        But if I programmatically change the label text, the grid doesn't change size, which is the effect I'm after.

        I'm guessing this is by design, so I was wondering if it's possible?

        Mark J

        1 Reply Last reply
        0

        1/3

        7 Jun 2019, 20:37

        • Login

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