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. QTableView resize columns for non-editable data
QtWS25 Last Chance

QTableView resize columns for non-editable data

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 3 Posters 1.4k 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.
  • A Offline
    A Offline
    Alexey Serebryakov
    wrote on last edited by
    #1

    Hi all!

    Please could any one help me, so I have readonly data into QTableView but I need can resize columns width (Interactive). How can do that?

    Thanks a lot.

    Ketan__Patel__0011K 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      What has readonly data to do with resizing the header? There are completely independent of each other.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      A 1 Reply Last reply
      1
      • A Alexey Serebryakov

        Hi all!

        Please could any one help me, so I have readonly data into QTableView but I need can resize columns width (Interactive). How can do that?

        Thanks a lot.

        Ketan__Patel__0011K Offline
        Ketan__Patel__0011K Offline
        Ketan__Patel__0011
        wrote on last edited by Ketan__Patel__0011
        #3

        Use NoEditTriggers Mode For ReadOnly
        Ans.PNG

        table_view->horizontalHeader()->setStretchLastSection(true);
        

        use this code for fit columns in your tableview

        1 Reply Last reply
        4
        • Christian EhrlicherC Christian Ehrlicher

          What has readonly data to do with resizing the header? There are completely independent of each other.

          A Offline
          A Offline
          Alexey Serebryakov
          wrote on last edited by
          #4

          @Christian-Ehrlicher because QTreeView::setEnabled(false) make disabled resize header columns.

          Christian EhrlicherC 1 Reply Last reply
          0
          • A Alexey Serebryakov

            @Christian-Ehrlicher because QTreeView::setEnabled(false) make disabled resize header columns.

            Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by Christian Ehrlicher
            #5

            @Alexey-Serebryakov said in QTableView resize columns for non-editable data:

            QTreeView::setEnabled(false)

            You did not wrote this - you said for non-editable data which is something completely different.
            QWidget::setEnabled() completely disables the widget - so no that's not possible in this case (and I don't see a reaons why it should)

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            A 1 Reply Last reply
            1
            • Christian EhrlicherC Christian Ehrlicher

              @Alexey-Serebryakov said in QTableView resize columns for non-editable data:

              QTreeView::setEnabled(false)

              You did not wrote this - you said for non-editable data which is something completely different.
              QWidget::setEnabled() completely disables the widget - so no that's not possible in this case (and I don't see a reaons why it should)

              A Offline
              A Offline
              Alexey Serebryakov
              wrote on last edited by
              #6

              @Christian-Ehrlicher I need user might be resize columns but can not change the data items.

              1 Reply Last reply
              0
              • Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by Christian Ehrlicher
                #7

                @Alexey-Serebryakov said in QTableView resize columns for non-editable data:

                but can not change the data items.

                Please see the post from @Ketan__Patel__0011 - and I also already said that editable and enable/disable are two different things! A disabled widget does not allow any user interaction because ... it is disabled.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                A 1 Reply Last reply
                3
                • Christian EhrlicherC Christian Ehrlicher

                  @Alexey-Serebryakov said in QTableView resize columns for non-editable data:

                  but can not change the data items.

                  Please see the post from @Ketan__Patel__0011 - and I also already said that editable and enable/disable are two different things! A disabled widget does not allow any user interaction because ... it is disabled.

                  A Offline
                  A Offline
                  Alexey Serebryakov
                  wrote on last edited by
                  #8

                  @Christian-Ehrlicher yeah but there not working correct. In my QTableView has one item is check box and another combox and I can check and popup them. :-(

                  So, I need doing the same as disabled but resizing headers are available.

                  1 Reply Last reply
                  0
                  • Christian EhrlicherC Offline
                    Christian EhrlicherC Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Then fix your model to not allow changing the checkbox state when it should be read only.
                    Disabling a widget is wrong in this case.

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    A 1 Reply Last reply
                    3
                    • Christian EhrlicherC Christian Ehrlicher

                      Then fix your model to not allow changing the checkbox state when it should be read only.
                      Disabling a widget is wrong in this case.

                      A Offline
                      A Offline
                      Alexey Serebryakov
                      wrote on last edited by
                      #10

                      @Christian-Ehrlicher thank you, looks good solution for me.

                      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