I use a subclassed QTableWidget with QTableWidgetItems in cells to display certain data. In the first row, I have a set of numbers separated by new lines in each cell. My problem is that when I increase font size/decrease cell size, some lines completely disappear, allthough the cell is definitely high enough to contain them.
This usually appears when there is a 2-digit number with some other lines under it and (probably) the font size is greater than the box width can match. I have the elide mode set to none to suppress the "three dots" that appear when this happens.
this->setTextElideMode(Qt::ElideNone);
The first row is resized by
this->resizeRowToContents(0);
this->setRowWidth(0, this->rowWidth(0) + 10);
so that its high enough.
However, the numbers keep on disappearing. Example shown here, note the font size change and missing numbers.
http://www.stud.fit.vutbr.cz/~xnavra23/TWIbug1.png
http://www.stud.fit.vutbr.cz/~xnavra23/TWIbug2.png
I'm starting to be quite desparate about this...any help highly appreciated.
Just to investigate the problem, try:
Make shure that string is correctly created (2,5,10,3) and not (10,3)
Try letters instead of numbers to make shure that they are shown
Try use 3digits nuber alongside with 2digits and see what is happened
May be workaround this by using 01,02 numbers?
Try resizeColumnsToContents() instead of setColumnWidth. If that doesn't work, try calling resizeColumnsToContents() before resizeRowToContents(0).
By the way, is there any reason for calling resizeRowToContents(0) instead of resizeRowsToContents() (note the different name)?
Related
I cannot somehow figure out how to resize the R graph, I am getting in my JupyterNotebook. No matter what I put in width or hight in options, it still remains this same.
The value of jobmemberid is a numeric data that I had to turn into a character. I feel like the bars are also of a different size, so it would be great to know if I can keep them constant.
Any hints how to go about it would be highly appreciated.
This is a workflow related question. I'm trying out working only (or mostly) in the Rmarkdown source window with the options set to "Chunk output inline". So with R open, there is just one big window -The environment, Console and File windows being minimized.
My question: Is there some option to change the number of columns displayed? I want to increase the numbers of columns visible without scrolling (see screenshot below), and since there is enough space I think it should be possible to display more of them.
Many thanks!
Solution: There is an option. Just add cols.print = 12 (or whatever number you want) to global options.
Also, people might find this 'manual' on markdown useful: https://bookdown.org/yihui/rmarkdown/html-document.html#paged-printing
In one of our pages I've created a detail screen with some information divided in blocks. I've used HorizontalLayouts with setExpandRatio for this. Here is how this is divided (all values made black for privacy reasons):
The final Label of the second row (now containing ---) should actually be empty instead. All the blocks are basically Vaadin Labels, with values in it. However, these values can sometimes be null, in which case I don't want to show anything in the Label.
When I use an empty String however instead of ---, it will look like this:
As you can see at the final Label of the second row, it is now missing it's border (and possible other styles we might add in the future), because Vaadin automatically put the expandRatio of Labels with an empty input to 0, turning the width to 0px.
I know you can set the actual width of a Label as filler, but in this case it's simply a question whether the value that's supposed to be in that Label is or isn't null.
I've also tried a space as value, but it just ignores it and behaves the same as the empty value. And when I " " as value (without setting the Label to HTML-mode), it outputs this literally as on the screen.
Is there any value I could use for the Label when the value is null to still show the style with borders, but without value?
EDIT: Hmm, when I use and set the ContentMode of the Label to HTML it seems to work. Is this the intended work-around for this issue (which means I'll have to set ContentMode to HTML for all Labels with the potential of containing an empty value), or is there another workaround by changing this 'empty' value alone?
Ok, I ended up using my solution provided in the EDIT. For all these Labels I had already created a BorderedLabel class, so I simply added setContentMode(ContentMode.HTML); to it, and used when the value is null in our util helper class.
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);
I added few extra columns, and now these X are back but only on the first line on certain columns. By X I mean the background the cell is crossed over like a large x. I used to have this issue before and solved it by setting the alternating color to white. Nothing else has been changed aside from adding 3 extra columns to the datagrid.
Anyone knows how to get rid of them? Thanks!
PS: whoever voted it for closing should really get off the high horse and get to work
It's probably that the columns are set to image columns and the image source is invalid. This has been my experience at least. Check the source you are providing for the image of the column.
Edit:
Then try handling DataError as it will also present red x's for columns that have thrown errors.
Apparently, CF doesn't like it when plus and minus signs are used in column.MappingName property. Hope this helps someone.