Set CONSTRAINED_RESIZE_POLICY for columns without first (for number of row) in tableView JavaFx - javafx

I have tableView with first column for row number. I would like to set CONSTRAINED_RESIZE_POLICY for all columns without first.
I made:
//First column implementation
column.setPrefWidth(40);
column.setResizable(false);
... //Make other columns
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
So I have first column with width I chose but other are wider than without last line in code above but still there is one additional void column.
And I have another question because I looked for resizing column to length of the longest text in column (I need it for first column) but I only found old answers with very long and tricky solutions. Is there any simple solution (method) to do it?
Edit: I found that when I try to manually resize columns, that they resize properly (as they should with CONSTRAINED) after only click to resize one of columns so I have a question, why they didn't resize from the start like I described above but after trying to manual resize. I think that problem is with setResizable false on first column but how can I repair this?

I found solution. To make other columns CONSTRAINED_RESIZE_POLICY there must be set size of the first column like below:
column.setMinWidth(40);
column.setMaxWidth(40);
and it's working without line setResizable(false).

Related

Libreoffice Calc Copy Formula Along Row Without Offseting The Functions Column Variables

I have a calc file with two spreadsheets in it. One that is called 'Master' has column A filled with text values. I need to copy those values onto the second spreadsheet along a row by using a formula like =$master(A1), however when you copy the formula along a row it also changes the variables to move along the row as well so instead of thew next cell being $master(A2) it ends up being $master(B1). How can you Keep the column the same but only increment the number? Like $master($A+COLUMN)
If tried OFFSET and INDIRECT but I cant get those to increment correctly either. It seems to me you should be able to do something like $master."A"&1 but that doesn't increment at all.
OFFSET should work fine, but you need to use the current COLUMN -1 as the offset for the row:
=OFFSET(master.$A$1;COLUMN()-1;0)
The -1 is needed since you start at the first column, but want to have an offset of 0. If you start at another column, adjust the subtraction accordingly.
Copy the formula along the row.

bootstrap stacking middle column

I just started using bootstrap.. i am trying to create a page with three column.
The middle column then needs to split into further ten rows. Each row will then have corresponding php echos
I have added the code on what i am doing on this page
http://www.bootply.com/BYbAeQUSsB#
I need to know if this is the right way of making rows in a column or is there another efficient way. i need to be responsive.

Dynamically display image in a Sharepoint 2010 list

I want to display image dynamically in a list. I have two columns in a list. The first column contains some numerical values and other contains smiley icon. My requirement is, if number in first column is greater than 50, I want happy smiley to be appear in a second column in a list, and sad smiley for less than 50 number. Currently I use hyperlink column to display image in a list. And I am adding image manualy.
I am looking forward, if it is possible to automatically display image based on first column number. Something like calculated columns. Lets say,
HyperLink/Picture Formula:
column =IF([someNumer]>50, "href = c:\Test\happySmiley.ico", "href= c:\Test\happySad.ico" )
I was wondering if we could do something like this, or any other suggestion is appreciated..
You are looking for KPI indicators.
You can also find great overview here:
How to create a SharePoint KPI column
And also check similar question on SPSE:
Make all KPI Status Icons in diamond shape

Sort vertical headers of QTableWidget

I have a QTableWidget that is used to display lots of data, basically derived from a function f(a,b). All a values go into the horizontal header, all b values into the vertical header and all f(a,b) into the corresponding cell.
The columns should be sortable. When a user clicks a column, all values in that column are sorted and all other columns are also "synchronized", since whole rows are sorted (using the clicked column as a sort criterium).
This works. Except for the "header column", the vertical header. The vertical header does not change, it does not synchronize with the reorganized rows. Is this the intended behaviour? Is it a bug in my code? How do I make the vertical header sort, too? Or do I need to add my b's to an ordinary column?
edit: I solved it now by making the header column an ordinary column. Though, I would still be interested in why the vertical header does not sort with the other columns.
Try to use QTableView instead of QTableWidget.
And use QAbstractTableModel for computing f(a,b)

How to make sure columns in QTableView are resized to the maximum

I'm not sure how to ask this, so, feel free to ask for more information.
It seems that tableView->resizeColumnsToContents() will only resize all the columns based on data in current view. Which means that if I have more data below (which is longer in terms of counts of words), those words will be wrapped down (if the wordWrap property is set to true).
The weird thing is, if I scroll down to the bottom and refresh the data, tableView will resize those columns correctly. It seems as if tableView didn't know there are longer text below.
So, my question is, how can I make sure those columns are resized to the max based on all of the data?
My codes
QSqlTableModel *model = new QSqlTableModel;
model->setTable("item");
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
model->select();
tableResult->setModel(model);
tableResult->setEditTriggers(QAbstractItemView::NoEditTriggers);
tableResult->setSelectionBehavior(QAbstractItemView::SelectRows);
tableResult->setSelectionMode(QAbstractItemView::SingleSelection);
tableResult->resizeColumnsToContents();
tableResult->resizeRowsToContents();
Update 1
I've tried tableResult->scrollToBottom() and it will only resize based on items at the bottom. So, if there are longer words in the middle, those words will get wrapped.
Update 2
If anyone would like to understand what I'm talking about, just download this example. You'll see that clicking the PushButton will generate a data that's not resized correctly.
Update 3
Possibly a bug: https://bugreports.qt.io/browse/QTBUG-9352
I managed to find a workaround for this issue, you just need to hide the table before calling resizeColumnsToContents().
For an example:
tableResult->setVisible(false);
tableResult->resizeColumnsToContents();
tableResult->setVisible(true);
I think that is because QSqlTableModel loads data on demand and the view calculates the column widths based only on data that is available. If you don't need your columns to be user-resizable, you can try this:
tableResult->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
I used the same workaround as described by amree, which worked great for the column widths, but tableView->resizeRowsToContents() wasn't working correctly if any offscreen columns had multiline cells that should have caused a row's height to increase.
I looked into the Qt source and it appears that some of the calculations depend on the viewport geometry. This seems to make everything work correctly for both columns and rows:
#include <limits>
tableView->setVisible(false);
QRect vporig = tableView->viewport()->geometry();
QRect vpnew = vporig;
vpnew.setWidth(std::numeric_limits<int>::max());
tableView->viewport()->setGeometry(vpnew);
tableView->resizeColumnsToContents();
tableView->resizeRowsToContents();
tableView->viewport()->setGeometry(vporig);
tableView.setVisible(true);

Resources