How to give TableWidget's Cells different width - qt

I want to resize the TableWidget's cell to have different width instead of having the same width for all columns...
I've tried to use ui->tableWidget->setColumnWidth(4, 10); and give the fourth column a fixed width but this has done no effect as you can see in the photo below:

Related

PyQt5 QTreeWidget column width

I am having troubles setting column widths with a QTreeWidget. The code snippet is as follows:
categories = QTreeWidget(my_widget)
categories.setColumnCount(2)
categories.setHeaderLabels(['Objects', 'Count'])
categories.currentItemChanged.connect(categoriesChanged)
vbox.addWidget(categories)
categories.setColumnWidth(1,66)
It seems like the final line isn't doing as I expected. Whst i would like is for the rightmost column to be much narrower than the left column.
By dragging the seperator in the header, I can successfully drag the columns to give the desired relative widths, and then by inspecting the categories.columnWidth property, I can see that the widths have changed, but I cannot seem to explicitly set the column width programmatically.
Thankyou,
Stuart
After asking around some more, I finally have the answer.
You can not set the width of the rightmost column because it is stretched to satisfy the minimum width of the width. Instead, the left column(s) can have their size set. I found that this causes the combined width of the two columns to exceed the width of the widget, and therefore a scrollbar appeared at the bottom of the widget. To get rid of this, the right column width can be set to a smaller width.
Hopefully someone else finds this useful.

In a 2-column Bootstrap row, how do I get the right-column (which has a background image) to always be the same size as the left column?

My Bootstrap page begins with a single row with two columns. In the first column there is some text content that varies in size. The right column will have a background image and the text in that column will always be about the same size. I want the right column to stretch to always be the same height as the left column and to also stretch when the user resizes the window so much that the right column becomes its own row beneath the left column. May I ask how to do this?
If you are using Bootstrap 3 and you don't want to use flexbox or Bootstrap 4, have a look here:
http://www.minimit.com/articles/solutions-tutorials/bootstrap-3-responsive-columns-of-same-height
It's pretty robust, just add classes for the row and desired columns (I usually use row-md-height and col-md-height, for smartphones it's usually not needed.

Table layout with %, Auto and px

I am trying to achieve the following table layout:
Third column fits to content in the cells.
The last one is fixed to 100px.
The two first columns share the rest space with the proportion.

repeat background

In a two column template, how can we use background on each column repeated when height of both columns differ?
eg, if my column 1 height is 200px (after loading some dynamic matter) and column 2 height is 500px, column 1 background is shown according to 200px height and column 2 background is shown according to 500px but i want both columns' background to be 500px.
Note: heights may differ because of dynamic content that will be loaded.
Ah, equal height columns. You can find dozens of techniques online using JavaScript, CSS, images, etc., all with varying degrees of success.
I'm a fan of faux columns, where you have a single background image that is the width of both columns, and that image is tiled in a container element that surrounds both columns. Then the background will extend as far as the tallest column. Theoretically, this same technique can be used for two, three, or more columns.
The original article is on A List Apart (http://www.alistapart.com/articles/fauxcolumns/), but the end result can vary a lot depending on your setup and structure.
Depending on other layout factors, an easy solution is to create a single background image that spans both, and set it as the background for the container element. That way, no matter which column has the vertically larger content, the background will span the entirety of it.
Of course, this really works best with fixed width layouts, etc.

Getting newly visible table data to not change column width

I have a table in which in one column some content is initially hidden, but appears on hover. The problem is that on hover the content then resizes that column's width and distorts the table.
How can I set the column to not resize itself without setting table layout: fixed or setting a width.
The table layout fixed causes columns to size themselves in unnatural ways, using only the first row, which is unacceptable due to the large variations in content length in different rows.
Is there a way to allow the table to size widths according to the longest column of any row, and then disallow resizing when it's hovering.
I'm using css hover to do my show hide if that's relevant. Thanks.
Why don't you just change the opacity attribute on hover, rather than the display attribute? So to reveal the content you would change opacity from 0 to 1, and to hide it from 1 to 0.
Hide the content using a div or a span which "covers" the column instead of hiding the actual content itself.

Resources