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. QWidget not resizing on QtDesigner
QtWS25 Last Chance

QWidget not resizing on QtDesigner

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 303 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.
  • W Offline
    W Offline
    wasawi2
    wrote on 27 Sept 2023, 13:30 last edited by
    #1

    Dear all,

    I have two identical projects, one uses QtDesigner to load some widgets and the other loads them directly from code. In both of them i wanted a widget to be resized when the user resizes the window. In the project that does not use QtDesigner that happens perfectly well but in the other identical QtDesigner project it does not resize at all.

    I have used the following code in my widget class to make the resize happen:

    void LineWidget::resizeEvent(QResizeEvent *)
    {
        m_defaultChartView->resize(size());
    }
    

    So for some reason the two projects, even if they are identical they do not behave in the same way.

    Any idea what might be going on?

    you can see the complete code of the project in my last post.

    Thank you for any hints.
    Best,
    w

    J 1 Reply Last reply 27 Sept 2023, 13:33
    0
    • W wasawi2
      27 Sept 2023, 13:30

      Dear all,

      I have two identical projects, one uses QtDesigner to load some widgets and the other loads them directly from code. In both of them i wanted a widget to be resized when the user resizes the window. In the project that does not use QtDesigner that happens perfectly well but in the other identical QtDesigner project it does not resize at all.

      I have used the following code in my widget class to make the resize happen:

      void LineWidget::resizeEvent(QResizeEvent *)
      {
          m_defaultChartView->resize(size());
      }
      

      So for some reason the two projects, even if they are identical they do not behave in the same way.

      Any idea what might be going on?

      you can see the complete code of the project in my last post.

      Thank you for any hints.
      Best,
      w

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 27 Sept 2023, 13:33 last edited by
      #2

      @wasawi2 said in QWidget not resizing on QtDesigner:

      i wanted a widget to be resized when the user resizes the window

      Why don't you simply use layouts?
      https://doc.qt.io/qt-6/layout.html

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      W 1 Reply Last reply 27 Sept 2023, 13:37
      2
      • J jsulm
        27 Sept 2023, 13:33

        @wasawi2 said in QWidget not resizing on QtDesigner:

        i wanted a widget to be resized when the user resizes the window

        Why don't you simply use layouts?
        https://doc.qt.io/qt-6/layout.html

        W Offline
        W Offline
        wasawi2
        wrote on 27 Sept 2023, 13:37 last edited by
        #3

        @jsulm thank you for answering.

        As you can see form the code in my previous post I have used QHBoxLayout both in QtDesigner and from code. The code veersion works as expected but the QtDesigner version does not resize.

        J 1 Reply Last reply 27 Sept 2023, 14:26
        0
        • W wasawi2
          27 Sept 2023, 13:37

          @jsulm thank you for answering.

          As you can see form the code in my previous post I have used QHBoxLayout both in QtDesigner and from code. The code veersion works as expected but the QtDesigner version does not resize.

          J Online
          J Online
          JonB
          wrote on 27 Sept 2023, 14:26 last edited by JonB
          #4

          @wasawi2
          Start by placing some breakpoints/debug messages e.g. in your resizeEvent()? Check the value of size().

          Not sure why you have to do this resize in code, but maybe. Your LineWidget instance(s) themselves have a layout onto which the chart view is placed?

          1 Reply Last reply
          1

          4/4

          27 Sept 2023, 14:26

          • Login

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