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. [Solved] Resize QDialog to fit all contents?
Forum Updated to NodeBB v4.3 + New Features

[Solved] Resize QDialog to fit all contents?

Scheduled Pinned Locked Moved General and Desktop
12 Posts 6 Posters 30.4k 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.
  • C Offline
    C Offline
    CAD_coding
    wrote on 25 Oct 2013, 11:13 last edited by
    #2

    This issue is really bugging me.
    Can I please have some guidance on this?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      CAD_coding
      wrote on 30 Oct 2013, 03:32 last edited by
      #3

      It would really help me if somebody could answer this question?
      Am I unclear in my question?

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JKSH
        Moderators
        wrote on 30 Oct 2013, 04:07 last edited by
        #4

        Hi,

        Calculate the "total width of all columns":http://qt-project.org/doc/qt-5.1/qtwidgets/qtableview.html#columnWidth, and then "resize your dialog":http://qt-project.org/doc/qt-5.1/qtwidgets/qwidget.html#size-prop accordingly.

        Similarly, resize your dialog when the number of views is changed.

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        0
        • C Offline
          C Offline
          CAD_coding
          wrote on 1 Nov 2013, 03:06 last edited by
          #5

          Hi JKSH,
          Thanks for your reply.
          I think I totally missed that... ;)
          But I was hoping something like QDialog::resizeToContents();

          1 Reply Last reply
          0
          • J Offline
            J Offline
            JKSH
            Moderators
            wrote on 1 Nov 2013, 04:10 last edited by
            #6

            You're welcome :)

            resizeToContents() would create a circular dependency -- a child widget's size depends on its parent's size, so we can't make the parent's size depend on the child's size too.

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            1 Reply Last reply
            0
            • C Offline
              C Offline
              CAD_coding
              wrote on 1 Nov 2013, 04:52 last edited by
              #7

              ohh...
              Got it!

              1 Reply Last reply
              0
              • P Offline
                P Offline
                poketmonister
                wrote on 1 Apr 2014, 15:00 last edited by
                #8

                very similar problem i have a QTableWidget instead of a QTableView

                and resizing QTableWidget to rows and columns does not increase QDialog size, only increases QTableWidget size.

                help me increase QDialog size also

                plz help me

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  Mar4eli
                  wrote on 1 Apr 2014, 17:22 last edited by
                  #9

                  i can't now tell about qDialog, but there is "resizeToContents" with the help of the widget.

                  1. Create widget (for example: mainWidget);
                  2. specify widget layout;
                  3. add some additional widgets inside layout.
                  4. mainWidget."adjustSize()":http://qt-project.org/doc/qt-5/qwidget.html#adjustSize
                  5. Enjoy.

                  If it is necessary, i can post example code tomorrow.

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    DBoosalis
                    wrote on 1 Apr 2014, 22:05 last edited by
                    #10

                    This might work:

                    Create your own class that inherits QTableView. Now QTableView has a protected virtual method it inherits from QAbstractScrollArea called viewportEvent ( QEvent * event ). I think you can can a contents resize event of the viewport judging by the 4.8 docs. So once you get the size you can emit a signal to the dialog to resize itself.

                    In the resizing of the QDialog you may need to disconnect or set a flags in our QTableview so as not to get the circular calling: QTable::resize->QDialog::resize->QTable::resize

                    1 Reply Last reply
                    0
                    • P Offline
                      P Offline
                      poketmonister
                      wrote on 2 Apr 2014, 11:52 last edited by
                      #11

                      hmmm....
                      Thanks for the reply, ill try it and post back

                      1 Reply Last reply
                      0
                      • W Offline
                        W Offline
                        WolfgangGriech
                        wrote on 17 Mar 2025, 01:39 last edited by WolfgangGriech
                        #12

                        I know it's more than 10 years later, but the same issue was bugging me now at some project, and I found a really easy solution:

                        just call 'resize(0,0)' for the QDialog widget itself, after setupUi() and after deleting (my case) or adding other widgets.

                        just saw that I forgot to mention a small detail, I also set the vertical size policy of the QDialog to 'minimum', but that on its own didn't do a thing...

                        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