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. Adjusting policy of QTableView to its content not working
Forum Updated to NodeBB v4.3 + New Features

Adjusting policy of QTableView to its content not working

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 6 Posters 1.6k 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.
  • Christian EhrlicherC Online
    Christian EhrlicherC Online
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote on last edited by
    #7

    Without a proper testcase the bug will be closed.

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

    E 1 Reply Last reply
    0
    • Christian EhrlicherC Christian Ehrlicher

      Without a proper testcase the bug will be closed.

      E Offline
      E Offline
      embeddedmz_2
      wrote on last edited by embeddedmz_2
      #8

      @Christian-Ehrlicher OK I ll do it. It's easy. I only have to open the links I have posted before (StackOverflow/github) and copy/paste the informations in the ticket description. Since I've done a lot of things before, I didn't think it was necessary to prove anything.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #9

        Hi,

        It has nothing to do with your previous work. Links and such can disappear at any time. Having everything available in the bug report directly allows people to get started immediately and not have to chase around for the required information that could get lost.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • E Offline
          E Offline
          embeddedmz_2
          wrote on last edited by embeddedmz_2
          #10

          @Christian-Ehrlicher @SGaist I have update the bug report.

          Here's how to reproduce this bug :

          • Clone this github repository : https://github.com/embeddedmz/QTableViewAdjustPolicyNotWorkingProperly
          • Open the CMakeLists.txt with Qt Creator (that uses Visual Studio 2019 64-bit compiler), build, run the program and note whether the QTableView fits its content.
          • Clone vcpkg : https://github.com/microsoft/vcpkg and follow the README.md's "Quick Start : Windows" section to set it up on a Windows OS.
          • Build Qt5 64-bit base binaries with vcpkg : .\vcpkg install qt5-base:x64-windows
          • Download and install CMake : https://cmake.org/
          • Use CMake to generate a Visual Studio Solution : launch CMake, in "Where is the source code:" indicate the QTableViewAdjustPolicyNotWorkingProperly repo path and in "Where to build binaries:" indicate a path where the Visual Studio solution will be generated.
          • Click on Configure
          • Choose Visual Studio 16 2019 as a generator
          • Ensure that the platform is x64
          • Click on "specify a toolchain file for cross-compiling"
          • Click "Next" and then specify the VCPKG toolchain file (e.g. D:/vcpkg/scripts/buildsystems/vcpkg.cmake)
          • Click Finish and then wait for CMake to complete its configuration, it must succeed !
          • Click on Generate
          • Click on "Open Project" to open the Visual Studio 2019 solution. You can then close CMake.
          • Build and run the Visual Studio solution.
          • Note whether the QTableView fits its content. Compare it with the result rendered with the program build with Qt Creator.

          It's your turn to play ! I did my job, now you do yours.

          JonBJ 1 Reply Last reply
          0
          • E embeddedmz_2

            @Christian-Ehrlicher @SGaist I have update the bug report.

            Here's how to reproduce this bug :

            • Clone this github repository : https://github.com/embeddedmz/QTableViewAdjustPolicyNotWorkingProperly
            • Open the CMakeLists.txt with Qt Creator (that uses Visual Studio 2019 64-bit compiler), build, run the program and note whether the QTableView fits its content.
            • Clone vcpkg : https://github.com/microsoft/vcpkg and follow the README.md's "Quick Start : Windows" section to set it up on a Windows OS.
            • Build Qt5 64-bit base binaries with vcpkg : .\vcpkg install qt5-base:x64-windows
            • Download and install CMake : https://cmake.org/
            • Use CMake to generate a Visual Studio Solution : launch CMake, in "Where is the source code:" indicate the QTableViewAdjustPolicyNotWorkingProperly repo path and in "Where to build binaries:" indicate a path where the Visual Studio solution will be generated.
            • Click on Configure
            • Choose Visual Studio 16 2019 as a generator
            • Ensure that the platform is x64
            • Click on "specify a toolchain file for cross-compiling"
            • Click "Next" and then specify the VCPKG toolchain file (e.g. D:/vcpkg/scripts/buildsystems/vcpkg.cmake)
            • Click Finish and then wait for CMake to complete its configuration, it must succeed !
            • Click on Generate
            • Click on "Open Project" to open the Visual Studio 2019 solution. You can then close CMake.
            • Build and run the Visual Studio solution.
            • Note whether the QTableView fits its content. Compare it with the result rendered with the program build with Qt Creator.

            It's your turn to play ! I did my job, now you do yours.

            JonBJ Online
            JonBJ Online
            JonB
            wrote on last edited by
            #11

            @embeddedmz_2 said in Adjusting policy of QTableView to its content not working with the Qt installed with vcpkg on Windows 10/VS 2019:

            I did my job, now you do yours.

            To be clear, this is not a Qt Company forum. The people answering your questions are end users just like you, who choose to give their time to help others. They do not have any "job" to do.

            You could wait to see if someone here chooses to look at your issue, or you could submit a bug report to The Qt Company's https://bugreports.qt.io/secure/Dashboard.jspa.

            E 1 Reply Last reply
            1
            • JonBJ JonB

              @embeddedmz_2 said in Adjusting policy of QTableView to its content not working with the Qt installed with vcpkg on Windows 10/VS 2019:

              I did my job, now you do yours.

              To be clear, this is not a Qt Company forum. The people answering your questions are end users just like you, who choose to give their time to help others. They do not have any "job" to do.

              You could wait to see if someone here chooses to look at your issue, or you could submit a bug report to The Qt Company's https://bugreports.qt.io/secure/Dashboard.jspa.

              E Offline
              E Offline
              embeddedmz_2
              wrote on last edited by embeddedmz_2
              #12

              @JonB By job I meant check the problem yourself and update the ticket status (I think Christian changed it). I know that it's very hard/impossible to fix issues in a very complex system (that's why I like the KISS principle but I'm obliged to use complex stuff to have food on the table). You've been picking on me when you didn't see that I already posted a link to the ticket I created. It must be the pollen allergy affecting your mood (I am the same, don't worry).

              JonBJ 1 Reply Last reply
              1
              • E Offline
                E Offline
                embeddedmz_2
                wrote on last edited by embeddedmz_2
                #13

                I just tried with Qt 6.2.3 provided by vcpkg (by the way, you will need to run windeployqt on the build's output directory, it does not work out of the box like Qt5) on Windows 10 and the size of the QTableView does not fit its content.

                Notice the difference between Windows 10 + Qt6 + vcpkg :
                alt text

                and Windows 10 + Qt5 + vcpkg : alt text

                1 Reply Last reply
                0
                • E embeddedmz_2

                  @JonB By job I meant check the problem yourself and update the ticket status (I think Christian changed it). I know that it's very hard/impossible to fix issues in a very complex system (that's why I like the KISS principle but I'm obliged to use complex stuff to have food on the table). You've been picking on me when you didn't see that I already posted a link to the ticket I created. It must be the pollen allergy affecting your mood (I am the same, don't worry).

                  JonBJ Online
                  JonBJ Online
                  JonB
                  wrote on last edited by JonB
                  #14

                  @embeddedmz_2 said in Adjusting policy of QTableView to its content not working with the Qt installed with vcpkg on Windows 10/VS 2019:

                  You've been picking on me when you didn't see that I already posted a link to the ticket I created. It must be the pollen allergy affecting your mood (I am the same, don't worry).

                  I certainly did not mean to "pick" on you, just to explain what can be expected here. My bad anyway, I did indeed reply to your post without seeing the context earlier on. We can blame it on the pollen! :) Ignore my earlier reply. apologies.

                  1 Reply Last reply
                  1
                  • E Offline
                    E Offline
                    embeddedmz_2
                    wrote on last edited by embeddedmz_2
                    #15

                    Under Qt 5.12.11, the bug does not exist. So I took a look at the QAbstractScrollArea::sizeHint code of this version and compared it with the implementation used in recent versions of Qt and found that setting verticalScrollBarPolicy to "ScrollBarAlwaysOff" the "AdjustToContents" adjustment policy works. The default value was "ScrollBarAsNeeded", in fact we can see that this value is not handled but since in Qt 5.12.11 we only compare the vertical|horizontal]scrollBarPolicy to Qt::ScrollBarAlwaysOn it prevents this bug from appearing.

                    The version used in the Qt github master branch :

                    QSize QAbstractScrollArea::sizeHint() const
                    {
                        Q_D(const QAbstractScrollArea);
                        if (d->sizeAdjustPolicy == QAbstractScrollArea::AdjustIgnored)
                            return QSize(256, 192);
                    
                        if (!d->sizeHint.isValid() || d->sizeAdjustPolicy == QAbstractScrollArea::AdjustToContents) {
                            const int f = 2 * d->frameWidth;
                            const QSize frame( f, f );
                            const bool vbarHidden = d->vbar->isHidden() || d->vbarpolicy == Qt::ScrollBarAlwaysOff;
                            const bool hbarHidden = d->hbar->isHidden() || d->hbarpolicy == Qt::ScrollBarAlwaysOff;
                            const QSize scrollbars(vbarHidden ? 0 : d->vbar->sizeHint().width(),
                                                   hbarHidden ? 0 : d->hbar->sizeHint().height());
                            d->sizeHint = frame + scrollbars + viewportSizeHint();
                        }
                        return d->sizeHint;
                    }
                    

                    The version used in Qt 5.12.11 :

                    QSize QAbstractScrollArea::sizeHint() const
                    {
                        Q_D(const QAbstractScrollArea);
                        if (d->sizeAdjustPolicy == QAbstractScrollArea::AdjustIgnored)
                            return QSize(256, 192);
                    
                        if (!d->sizeHint.isValid() || d->sizeAdjustPolicy == QAbstractScrollArea::AdjustToContents) {
                            const int f = 2 * d->frameWidth;
                            const QSize frame( f, f );
                            const QSize scrollbars(d->vbarpolicy == Qt::ScrollBarAlwaysOn ? d->vbar->sizeHint().width() : 0,
                                                   d->hbarpolicy == Qt::ScrollBarAlwaysOn ? d->hbar->sizeHint().height() : 0);
                            d->sizeHint = frame + scrollbars + viewportSizeHint();
                        }
                        return d->sizeHint;
                    }
                    

                    Can someone update the status of this ticket : https://bugreports.qt.io/browse/QTBUG-101874

                    in any case, this method must be rewritten and it may not be obvious to handle the "ScrollBarAsNeeded" case at first glance

                    1 Reply Last reply
                    0
                    • E Offline
                      E Offline
                      embeddedmz_2
                      wrote on last edited by embeddedmz_2
                      #16
                      This post is deleted!
                      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