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 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

    jsulmJ 1 Reply Last reply
    0
    • W wasawi2

      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

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on 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
      2
      • jsulmJ jsulm

        @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 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.

        JonBJ 1 Reply Last reply
        0
        • W wasawi2

          @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.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on 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

          • Login

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