Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label wrapped vertical size #41

Open
jamesdbrock opened this issue Sep 15, 2023 · 6 comments · May be fixed by #117
Open

Label wrapped vertical size #41

jamesdbrock opened this issue Sep 15, 2023 · 6 comments · May be fixed by #117

Comments

@jamesdbrock
Copy link
Member

jamesdbrock commented Sep 15, 2023

This vertical size calculation is wrong if word_wrap=True.

self._set_size(size * len(str(self.props.text)), size, lambda size: (size * len(str(self.props.text)), size))

https://doc.qt.io/qtforpython-6/PySide6/QtWidgets/QLabel.html

@jamesdbrock
Copy link
Member Author

jamesdbrock commented Nov 26, 2023

word_wrap=True size calculations seem to work okay if you don't set the "width" of Label directly, and instead set the "width" of its containing layout widget. (PySide6 v6.6.0)

@jamesdbrock
Copy link
Member Author

“If you want the QLabel to fit the text then you must use adjustSize()”
https://stackoverflow.com/questions/48665788/qlabels-getting-clipped-off-at-the-end/48665900#48665900

@jamesdbrock jamesdbrock reopened this Dec 9, 2023
@jamesdbrock
Copy link
Member Author

https://doc.qt.io/qtforpython-6/overviews/layout.html#layout-issues

“The use of rich text in a label widget can introduce some problems to the layout of its parent widget. Problems occur due to the way rich text is handled by Qt’s layout managers when the label is word wrapped.”

@jamesdbrock
Copy link
Member Author

@jamesdbrock
Copy link
Member Author

jamesdbrock commented Feb 25, 2024

https://stackoverflow.com/questions/14238138/heightforwidth-label

I've put C++ code at http://egret.psychol.cam.ac.uk/code/2017_01_16_qt_height_for_width/ for the following layouts:

Link is broken but the code is in the Wayback machine: https://web.archive.org/web/20191221090125/http://egret.psychol.cam.ac.uk/code/2017_01_16_qt_height_for_width/

Also on Github https://github.com/ucam-department-of-psychiatry/camcops/tree/master/tablet_qt/layouts

Query to the author ucam-department-of-psychiatry/camcops#339

@jamesdbrock
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant