JavaFX tableview remove default alternate row color - css

I coulnĀ“t find any example that completely removes/hides this behaviour. Most of those examples painted the rows based on their values, still, empty rows were printed(odd:white, even:gray) and they completely ignored any css code or setStyle. Is it posible to force a tableview to stop printing innecesary/empty rows that just are there to fill the empty space left between the last filled row and the max height of the tableview?

In your external CSS file, do
.root {
-fx-control-inner-background-alt: -fx-control-inner-background ;
}

Related

Oracle Apex-Color specific Interactive grids cells based on position

I need help with css styling of interactive grid.
In my requirement, the rows of grid are fixed. In the rows some cells are blue/some grey and so on.
In this case what css style/js can be used to point to a particular cell at particular index in ig and use colors?
So, in short the requirement is different colors for different cells for fixed rows IG.
Oracle Apex-20.2
Ex:
Do the grid cells need to be editable? If not you can do this:
Add columns based on CASE expressions to define CSS classes for particular values e.g.
case col1 when 'C' then 'class1'
when 'H' then 'class2'
...
end as col1_class
Change the column type to HTML Expression
Set the column's HTML Expression property to:
<div class="&COL1_CLASS.">&COL1.</div>
Set up CSS to define the classes - e.g. in the page inline CSS:
.class1 {background-color: #fd0}
.class2 {background-color: #aaa}
...
Here is an example where I have done this to highlight the job MANAGER in red:
You can add further CSS to remove padding from the cells, add padding to your divs etc.

Set minimum row-height of QComboBox

I am trying to set the minimum height of the rows in the QComboBox dropdown menu without changing their width or the size of the QComboBox itself.
By default the width and height of the row items are calculated by its data. To make the dropdown list resize to the width of the data I am calling
view()->setMinimumWidth(view()->sizeHintForColumn(0);
in the combobox's ::showPopup().
However, since I have different font sizes in rows, I would like to enforce a minimum height on each row.
I tried to use setSizeHint on each QStandardItem that is added in the first column to the rows but without success. I tried:
item->setSizeHint(QSize(item->sizeHint().width(), minHeight));
(https://stackoverflow.com/a/10749345/1981832)
But this lead to the dropdown menu not resizing to the data's width.
So, I tried to leave the width "unset". However, both
item->setSizeHint(QSize(QSize().width(), minHeight));
and
item->setSizeHint(QSize(0, minHeight));
did not work. Does anyone have an idea how I can enforce a minimum height on the rows of the QComboBox without messing up the automatic width calculation?
Just use this lines:
QComboBox combo;
QListView *view = new QListView(&combo);
view->setStyleSheet("QListView::item{height: 100px}");
combo.setView(view);
Or write this code in qss file:
QListView::item {
height: 30px;
}
After that use:
QComboBox::setView(QAbstractItemView *itemView)

Always have an empty TableRow at the bottom of the TableView

I have a TableView where I add a new row by right clicking on the row below where I want to place the row and choosing "add" in a context menu. This becomes a problem when the TableView has so many rows that the entire view is filled with filled rows, since no empty rows are displayed. When this happens, I can only add a row above the row at the bottom, but not below it.
Adding a "dummy item" to the bottom of the TableView when that is used is not an option. I need to add a TableRow that has a item that is null, like the rows that usually fill out the viewport of the TableView when there's not enough items to fill the viewport.
Is there a way to make sure that there's always a TableRow with no item at the bottom of the table?
Edit: Adding a context menu to the entire TableView and automatically add row at the bottom when that is used is not an option either. This is because I need to add a style class to the row below the input index to provide the user with feedback on where the row will be placed. Therefore there needs to be a TableRow object to add the style class to.
Edit: I realize my text was a little bit messy. Here's an attempt at clarifying the actual behaviour I want:
I don't want the viewport to always display an empty row at the bottom, which would be some kind of "sticky row" behaviour. I want the actual table to display an empty row after the last row. I.e: When I'm in the "middle" of the list, and can't see the last row, no empty row should be displayed. The only time the empty row is needed is when I want to add an item at the end of the table list. Therefore when I scroll down so I see the end of the list, that's when I need an empty row. The reason I need this exact behaviour is explained in the original text.

JavaFX 2.2 Remove Show-Hide-Column Button in TableView and change position of column sort arrow

I have two problems with the TableView in JavaFX 2.2. First of all, have a look the following image:
As you can see I have an TableView with five columns. I used CSS to remove the vertical separators and the background color. However, I cannot remove the right 'column', which is the 'TableMenuButton'. It is somehow connected to the css class .table-view .show-hide-columns-button and .table-view .show-hide-column-image. I tried to make it transparent, remove the effects and many other things, but with nothing worked out.
The second problem is the sorting arrow in the table header. The column headline is aligned to the left, so I need to display the arrows on the left side as well. Otherwise, the user might think the column to the right is currently sorted (e.g. have a look at the image above). Is there an easy way to do this? I tried -fx-alignment: left; and other css commands, but again without any success.

How change the background color for a blank cell in QTableWidget

If a cell have some data, using
tableWidget->item(8,0)->setBackgroundColor(Qt::red);
to change the background color will work, but if a cell is blank it will fail.
You cannot set the background color of a cell unless it contains a QTableWidgetItem (as the background color is a property of the item).
So you need to populate your QTableWidget with empty items first. In your example, create the item before you attempt to set the background color.
tableWidget->setItem(8, 0, new QTableWidgetItem);
tableWidget->item(8, 0)->setBackground(Qt::red);
Please also note that you should use setBackground instead of setBackgroundColor as the latter is deprecated.

Resources