I want to use a QTreeView (PyQt5) and set its height according to the number of first-level entries the model has.
This is because I don't know how many entries there will be to show, and I don't want to spend the default height of the widget when there is only one entry.
So what I need and didn't find yet is a way to
determine the height of the rows (they will be single-line strings so I can set it to uniform height if that helps)
set the exact height of the QTreeView in relation to a multiple of the row's height.
(I'll experiment with minimum and maximum numbers and padding if necessary)
Related
Does the Datagrid support the notion of varying the number of data rows according to the available vertical space?
Hence, as the browser changes size the table header and footer areas remain fixed in size and the data area space varies to show whatever number of rows that will fit in the available vertical space.
This is to avoid a situation where scrolling is required.
Clarity does not have this feature, but you could manually set the height of the Datagrid in the application based on the number of rows you have displayed. The goal currently is to minimize vertical jumpiness, so we keep the same height.
I am running into a weird scenario where I don't understand the output of adjustSize(). I am calling adjustSize() on a QLabel, and the resulting size does not match the minimumSizeHint or the sizeHint - it is in between. The only other factor I can imagine is the length of the text inside the QLabel, but I get the same result for differing lengths, so that doesn't seem right either.
Here is the exact scenario:
I have a horizontal layout containing two QLabels.
One QLabel contains text and has a fixed width fw and minimum height mh. If all the text can fit within that size, the dimensions should be exactly fw x mh. If there is more text, the height should increase.
The second QLabel contains a pixmap and should always maintain its aspect ratio. The minimum width and minimum height exactly match the pixmap's original dimensions. If the height of the text-based QLabel increases, this second QLabel needs to increase in both width and height to match the text-based QLabel's new height while maintaining the aspect ratio of the pixmap.
This seems like it should be readily do-able. After the text of the first QLabel is changed (dynamically to any arbitrary length (within reason, not going outside the bounds of the screen or anything)), I call adjustSize() on that first QLabel. Then, based on the resulting height, I calculate the scale factor that the pixmap would have to increase by to match that height and reset the pixmap with scaled height and scaled width.
The problem is that the height of the text-based QLabel does not behave in any reasonable way I can discern. Even with drastically smaller text than what can fit in the starting size, adjustSize() still results in the height increasing past that starting minimum. Here I'm going to use some exact numbers to illustrate the issue. The minimum height is 385. The sizeHint says 401, and adjustSize results in 390. Why is the sizeHint 401 when the text can easily fit in the minimum of 385? And why is 390 chosen by adjustSize(), matching neither value?
I have an application with width/height of 100%. I have several nested groups within and their measurements are all not set, instead being defined as top=5 or left/right=10, etc.
I'm trying to get the actual with of a group that should be 390. I've set the swf object size to be 400 from the html embed code, and the group is inside another group that is width=100%. The group has a left=5 and right=5 so the width should be 400-10. When I display the .width and .measuredWidth of this group, the width is always 400.
I'm fairly new to flex/flash. Do I need to have explicitly set widths in order to get the width of child containers? Is there something I'm doing wrong here?
Thanks!
Percentage size of Component is calculated at parent's updateDisplayList(),so it's available only through width & height.
Methods getExplicitOrMeasuredWidth/Height() may return following:
Explicit width/height
Or
Measured width/height when mode is set to Wrap. This is calculated during Component's measure().
If you do not plan to override measure or updateDisplayList you simply should not use getExplicit... at all.
Use the getExplicitOrMeasuredWidth() method of the UIComponent. This returns the explicit width if set (e.g., width="700") or the measured width (in pixels) if not. If a percentage width is set, it returns the actual measured width.
It turns out there was an inner group with a path that was throwing the layout off. When I removed this element, the .width property worked as it had before.
One thing that surprised me is that .measuredWidth and getExplicitOrMeasuredWidth() both returned 10 when .width returned 390.
I believe that it's returning the right value. If you have an application A, width 400. Then you put group B inside it with width 100% and some padding. Group B really is 400, because it's extended all the way to the edges of the application. However, by giving it left/right/padding/whatever, it, in turn, can adjust its children so they aren't so close to the edges. You may need to look for the maximum width of group B's children to get what you want.
Update:
According to documentation:
http://livedocs.adobe.com/flex/3/html/help.html?content=size_position_5.html
Using constraint-based layouts overrides width and percentWidth. Try measuredWidth, though it may not be filled until the component has had time to go through its measure() phase during invalidation...
I have a DataGrid that has between 4-10 columns. I want the columns to be of width '50'. I have already set the width attribute in MXML. I am using "colName.hide = true" to hide various columns depending on whether I have data. I find that my columns expand when I have less columns. Is there a way to set the max width of a column or force it to keep the same width?
Why not just resize the width of the datagrid itself to 50 * amtOfCols when columns are hidden and shown?
You have to leave one column with undefined width - it will stretch when parent (grid) will be resized.
Or, you should recalculate and apply width of the greed dynamically
I have custom list item renderers and editors for a List control. I need for the editor to have a greater height then the renderer, i.e., the row should expand(in height) when it goes into edit mode. However, even when the list's variableRowHeight is set to true, it doesn't do what I want: the height seems to be based on the height of the renderer only, not the editor. Is there any way to do what I want?
Have you tried setting the height of each of the renderers on the row that the editItemRenderer is on.
If my memory serves me correctly the varible row height takes its height from the first column cells (this may be wrong?)
If you have varibleRowHeight then when you go to edit a cell make sure all cells in the row are the same height and you may also have to invalidate the size and display.
If you have already solved this post your answer as it would be interesting to see what different approaches you may have taken.