Adjusting policy of QTableView to its content not working
-
Hello,
This is really a strange problem and I hope that someone can understand it !
StackOverflow question : https://stackoverflow.com/questions/69042445/adjust-qtableview-height-to-its-content-few-lines
Issue on vcpkg I have posted today : https://github.com/microsoft/vcpkg/issues/23561
The QT version installed by vcpkg 5.15.3 (but back then it was another old version and the issue still existed, so I think it is not related to a specific Qt version).
Thank you.
-
qtcreator + 5.15.2 + windows 10 = OK
vcpkg + 5.15.2 + windows 10 = FAIL
vcpkg + 5.15.3 + windows 10 = FAIL
vcpkg + 5.12.5 + Windows 8.1 = OK
qtcreator + 5.15.2 + windows 8.1 = FAIL -
Qt Creator has nothing to do with running code. Do you perhaps mean a MingW build of the Qt libraries?
@ChrisW67 In the vcpkg issue (link above) I have opened, someone posted this :
QtCreator and CMake may use different manifests for dpiAwareness, but it is only noticable if you enabled resolution scaling in windows. At this point I would just step into Qt code and debug it. Also, search for it in Qt bug tracker.
Where can I report this Qt bug ? or should I say where is the Qt bug tracker ?
-
@ChrisW67 In the vcpkg issue (link above) I have opened, someone posted this :
QtCreator and CMake may use different manifests for dpiAwareness, but it is only noticable if you enabled resolution scaling in windows. At this point I would just step into Qt code and debug it. Also, search for it in Qt bug tracker.
Where can I report this Qt bug ? or should I say where is the Qt bug tracker ?
-
I created this ticket : https://bugreports.qt.io/browse/QTBUG-101874
Inside it, I uploaded 4 screenshots to share with you this bug.
You see people, complexity ain't good ! I prefer using C and Tcl-Tk than the complex, ugly and unreliable stuff we have today...
-
Without a proper testcase the bug will be closed.
-
Without a proper testcase the bug will be closed.
@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.
-
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.
-
@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.
-
@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.
@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.
-
@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.
@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).
-
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 :
and Windows 10 + Qt5 + vcpkg :
-
@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).
@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.
-
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
-
This post is deleted!