How to avoid the ugly empty space of the placeholder for the vertical scrollbar in QTableView? - qstandarditemmodel

In a QTableView instance, rows are variable, the row count are not fixed most of the time. In a moment, if the row count is lower than the display count of the viewport, a ugly empty-space placeholder for the vertical scroll bar will show up as in the below picture.
I tried viewportSizeHint(), maximumViewPortSize(), ... finally, a very simple solution.

Solution: If there is a n-column table originally, super().__init(m,n+1) should be called. The extra empty column is to fix the visual effect.
The last thing to remind, just ignore this extra column. Ignore it! No need any other specific codes for it. No any bad side effects have been found until now.
Feel free to post your reviews.
class KBWWTableModel(QtGui.QStandardItemModel):
def __init__(self, parent: QtCore.QObject=None):
# add a extra empty column to fix the visual effect
# super().__init__(1, 3, parent=parent)
super().__init__(1, 4, parent=parent)

Related

Hide empty rows in group-header in ag-grid

How can i hide this group-header-row(red-box in picture). In this example i have one more hiden column, which has more sub-levels(childs). If they are are'nt shown, they stay as empty line, for this reason header has huge height in some tables. Idk how can i solve this problem. I didnt find in ag-grid api functions or somthing can help.
Image with example

Swift: Auto Layout - Columns of Text - removing trailing and leading warnings

I have two columns of text. The left is anchored top, left and bottom and the righthand side conversely. This still generates leading and trailing warnings. How do I connect the two columns' rows to tell Auto Layout to just expand the space in between?
While YOU know exactly what text you're going to put into those labels, Storyboard / Interface Builder (IB) has no idea.
So this looks great to you:
But... what happens if the "Date" text changes to "When do you want to get started?":
Because we haven't given a constraint between the two labels, they overlap.
So, let's do the same thing on both "rows" but, add a Trailing-to-Leading constraint of 8 between the labels:
We've prevented the overlap but now we see a new problem (that IB will warn you about)... Which label should get compressed? IB (and auto-layout at run-time) will make its own decision, which may not be what you want, and which may be inconsistent between similar layouts.
To fix that, we give a higher Content Compression Resistance Priority to the label we do not want compressed:
And here is the result - top "row" has the left-hand label at the default of 750, and the right-hand label at 751, and the bottom "row" has the left-hand label at 751, and the right-hand label at the default of 750:
It looks the same as "C" but we no longer have errors/warnings from IB.
So, even if you know the text in your two columns will never be enough to overlap, IB is going to encourage you to provide enough constraints (and priority settings) to make sure you get exactly what you want.

How to add space between rows in NSTableView

I'm trying to add spaces in between rows in an NSTableView, like how it looks here.
Currently, however, my rows look like this, with 0 spacing between them.
Is it possible to add these spaces? I found this post on how to do it, but that's for UITableView, and I don't think you can add sections with NSTableView. Another thing I tried was using intercellSpacing on the table view, like so:
tableView.intercellSpacing = NSSize(width: 0, height: 80)
However, that just increases the height of each row rather than increase the space between them.
Lastly, I looked into drawSeparator, which seems promising but has limited documentation. Would extending NSTableRowView and overriding the drawSeparator method work, basically by drawing in a blank space as the separator? If so, how would I go about making my table view use my custom row view class?
If none of these options work, I'd also be open to faking the effect, maybe by having the actual content of a row be smaller than the row itself and using the remaining space as the padding between rows. However, I'm not sure if this would work, given that right now I'm using NSShadow, which highlights the boundary of each row.
Found a way to work around this issue. Before, each row consisted of two columns, one for the text fields and one for the buttons. However, I've changed it by putting all the text fields and buttons into a single column, that way there's only one cell per row. I then can apply the NSShadow and other styles to the NSTableCellView rather than the NSTableRowView. This means that I can now use intercellSpacing to create vertical spacing between cells:
tableView.intercellSpacing = NSSize(width: 0, height: 80)
The rows are still touching, but I've disabled the borders/highlighting on them so you can't actually see them. The cells, on the other hand, are visible, and you can adjust the spacing/styles on them as necessary.

iReport - How to prevent texfield go to next page

I need help!
When Textfield Text is too big and does not fit all the content on the page, it is automatically moved to the next page, can anyone help?
The result is the following:
The structure of the report is as follows:
structure of the report
The expected result would be to completely fill the first page, and then break to next.
You can manage your detail band selecting it and change the property Split type as the following image:
The meanings of three options:
STRETCH:
The band is allowed to split, but never within its declared height. This means the band splits only when its content stretches.
PREVENT:
Prevents the band from splitting on first break attempt. On subsequent pages/columns, the band is allowed to split, to avoid infinite loops.
IMMEDIATE:
The band is allowed to split anywhere, as early as needed, but not before at least one element being printed on the current page/column.
You can see here

stretch a textField to a max height in jasper reports

I think this is more of a general issue. I would like to use a textfield that gets dynamic data and doesn't stretch more than a given max height. For instance, I have a textfield that, if it gets text that fits in one line, the textfield will be one line height, and i have other elements under it, that will move up with float positioning. Or, if I want a 3 line max height and if the text exceeds that space, then the rest will be trimmed.
I don't want to use java expressions to trim that text, as it is not always accurate. I am new to jasper and I am trying to know if there is any way to do this. I did a lot of searches, but maybe there is something that i missed, and i hope someone can help me. Thank you
I managed to solve this by extending net.sf.jasperreports.engine.fill.TextMeasurer and overriding initialize() method; also I had to extend net.sf.jasperreports.engine.util.AbstractTextMeasurerFactory and override the createMeasurer() method.
Now, whenever I want to have max # of lines, with no overflow, I add a property to that text field (e.g. maxLines) which is being passed to my custom TextMeasurerFactory. I hope this helped you.
We had a similar problem at work with JASPER Reports 4.5, where we had an invoice with a header and a table. We wanted the header to have dynamic height based on the lengths of certain fields (like address, partner name, etc,), but not more than a critical limit, otherwise the header will push the table and thus making a mess by splitting it across multiple pages. Also, the invoice shouldn't exceed 1 page.
We eventually had to move the header in the background section, where we also put a background for the table consisting of vertical lines (so it will extend to the end of an A4 page) and a white opaque square.
This way, if the header exceeds the max height it will go underneath the table's background, cropping the text. This was the desired effect we were looking for.
Sounds crazy, but it worked ...