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. Resize dialog when it's child table resizes
Forum Updated to NodeBB v4.3 + New Features

Resize dialog when it's child table resizes

Scheduled Pinned Locked Moved General and Desktop
12 Posts 5 Posters 7.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.
  • A Offline
    A Offline
    Anticross
    wrote on last edited by
    #1

    I've got dialog in *.ui file, which contains some children like: labels, comboboxes, etc. Most place is taked by QTableWidget. When I change count of rows(columns) in it, it automatically shows sliders to scroll the content. But I need other thing: If my table gets bigger I need to resize my parent widget (QDialog) to sizes when all content of my table is shown, and if table gets smaller leave existing sizes.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chuck Gao
      wrote on last edited by
      #2

      Use layout and signal/slot. But i think the common way is resize the dialog, and then the table's size changes

      Chuck

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Anticross
        wrote on last edited by
        #3

        I already apply layouts but for table it has no effect. What signals and slots you mean ? Of-course it changes when the dialog has been resized, but I don't know how much bigger I must make my dialog, to all content of table has been shown.

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          ZapB
          wrote on last edited by
          #4

          What do you want to happen when you reach or exceed the screen height?

          Nokia Certified Qt Specialist
          Interested in hearing about Qt related work

          1 Reply Last reply
          0
          • L Offline
            L Offline
            ludde
            wrote on last edited by
            #5

            Have you tried to set the scrollbar policy of the table widget to always off?

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dakron
              wrote on last edited by
              #6

              Anticross: look at "this":http://stackoverflow.com/questions/1850391/how-do-i-resize-qtableview-so-that-the-area-is-not-scrolled-anymore

              1 Reply Last reply
              0
              • A Offline
                A Offline
                Anticross
                wrote on last edited by
                #7

                to ludde: I'll tried to do this:--
                @m_ui->tableWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
                m_ui->tableWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @
                But I only lost my scrolls without any resizes.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  Anticross
                  wrote on last edited by
                  #8

                  This code from
                  [quote author="dakron" date="1310030727"]Anticross: look at "this":http://stackoverflow.com/questions/1850391/how-do-i-resize-qtableview-so-that-the-area-is-not-scrolled-anymore[/quote]

                  @ QRect rect = m_ui->tableWidget->geometry();
                  rect.setWidth(2 + m_ui->tableWidget->verticalHeader()->width() +
                  m_ui->tableWidget->columnWidth(0) + m_ui->tableWidget->columnWidth(1) + m_ui->tableWidget->columnWidth(2));
                  m_ui->tableWidget->setGeometry(rect);@

                  Has bad results. I've got Half of my table shown in dialog after calling adjust size.

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    Anticross
                    wrote on last edited by
                    #9

                    [quote author="ZapB" date="1310029477"]What do you want to happen when you reach or exceed the screen height?[/quote]

                    Nothing, I just want to resize by calling some function in class which using my *.ui, and if it reach screen size user can manually resize dialog.

                    1 Reply Last reply
                    0
                    • Z Offline
                      Z Offline
                      ZapB
                      wrote on last edited by
                      #10

                      And how do they do that if the bottom edge of the window is off the bottom edge of the screen? Why not just let the user manage the window size like nearly every other application does. I do not understand your use case I guess. Could you elaborate as to why you want to do this please?

                      Nokia Certified Qt Specialist
                      Interested in hearing about Qt related work

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        Anticross
                        wrote on last edited by
                        #11

                        First thing - user can fit window to screen size by clicking on OS toolbar and choosing fit_to_window. I need it because my table have some number presets, I mean I have logically many tables of different sizes, and The data which contains on it is visually perceptible better when all table shown, not the part of it. And also these tables are not so big to occupy all screen.(but of-course you right that I need to proceed this situation too).

                        1 Reply Last reply
                        0
                        • Z Offline
                          Z Offline
                          ZapB
                          wrote on last edited by
                          #12

                          If you are sure you want to go down this route then I think probably your best option is to subclass QTableView and override the sizeHint stuff so that the table returns sizehints suitable for the contents they are showing. The Qt layout system should then take care of the rest of it for you.

                          That is not to say that calculating suitable size hints will be easy. You will need to query things like number of rows and their sizes (or are they all the same size), style metrics (since different styles have different size requirements), margins, font sizes etc.

                          Nokia Certified Qt Specialist
                          Interested in hearing about Qt related work

                          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