QTableView sizing issue - c++

I am using Qt 4.2. I have a window with two separate tables using the QTableView and QAbstractTableModel. The tables seem to have extra space below the rows ending, and to the right of the columns ending. My solution up to this point with other windows has been to calculate the size of the table (based on cell size, plus a little extra for the border) and set the fixed width and height. This solution is a pain for tables that have different size columns. I am looking for a solution where my QTableView class does not have to set its own fixed size, but rather the table just ends at the last row and column. I do not want to use setStretchLastColumn(). Any suggestions to get these tables to behave properly without having to calculate and set a fixed size would be very helpful. Thanks.

Related

QTableView, strech all section but the last one resize to content

My table consists of 2 columns: the 1st one stores some strings, the other contains a checkbox only. To make my table a little bit fancy I want to stretch the whole table to the width of its view.
Using
setStretchLastSection(true);
solves the 1st problem. The table looks better, but... OK... the last column is a bit large.
Also I can use
setSectionResizeMode(QHeaderView::Stretch);
The table looks great, but... It isn't my desire. The 1st column should be optimally at least 90% of view's width and the 2nd one small since it contains one checkbox only. Additionally the table shoub be stretched to the view's width. Any Ideas?
Here is a picture just to make my question more understandable)
Here is the solution:
Disable the stretch option for the last column
setStretchLastSection(false);
Set a fixed width for the last column
setColumnWidth(1, fixedWidth)
Stretch the first column
setSectionResizeMode(0, QHeaderView::Stretch)
a bit fancy look

Can we hide 1/2 columns while displaying wxtreelistctrl?

I am using wxtreelistctrl to construct a tree and I want to store 4 columns in it, but while displaying I want to display only 2 columns. Is there any way I can do this?
With wxTreeListCtrl this is not directly supported, but you could set column width to 0 as a quick and dirty hack.
With wxDataViewCtrl itself, you can perfectly well show just some of the columns of your wxDataViewModel in the GUI control.

How to provide a custom column width calculation for CListCtrl?

I'm using a CListCtrl with my own "DrawItem" to draw some custom graphics into the first column, in front of the text. The text is moved ~20 pixels to the right for this. That part works.
If the user double-clicks the column divider in the header, Windows calculates the best column width. But of course Windows doesn't know my custom drawing. So the result is ~20 pixels too small for the first column.
How can I correct that?
Found a workaround:
I can trick MFC into thinking that the list control uses checkboxes:
pMyList->SetExtendedStyle(pMyList->GetExtendedStyle() | LVS_EX_CHECKBOXES);
The user will never ever see the system's checkboxes (because of my custom drawing), but this gives me just the space that I need.

How to set minimum width for the first column of the QFormLayout?

How to set minimum width for the first column of the QFormLayout? I can do it for QGridLayout by using QGridLayout::setColumnMinimumWidth(int, int), but cannot find a method to do that for QFormLayout.
It's pretty simple to do. Just set a minimum width on any of the widgets that you've inserted into the first column.
How to set minimum width for the first column of the QFormLayout?
You cannot (off-hand). It was not designed for that as this sounds more like a QGridLayout feature. You could either refactor your design to use QGridLayout, or you could potentially set the size for the rows as you wish, but you would execute that on the row content rather than the layout itself.

Infragistics XamGrid with different row heights

I have a XamGrid that I've got displaying several dynamically generated columns, and one of those columns can have a listbox in it that sizes itself according to how many items are in it (but has a maximum height constraint). I want each row of the XamGrid to basically only be as large as it needs to be - which they are at first, but after scrolling up and down the contents of the grid a bit I find that rows that had hardly any values in the listbox (so should be fairly small in height) are now the same height as the largest rows I've scrolled into view previously. The result is a lot of wasted space, so I'm wondering if anyone knows of a way to make it so that the rows don't automatically resize themselves to match the largest row that has been loaded. I've tried taking a look at the control template but all I see in it are 3 parts and can't see any way to edit or look inside those parts.
PS I would have posted this on Infragistics own support forums but I can't for the life of me actually find any way to post new topics on there even when signed in with my IG account... great design.
Thanks
Chris
Set the RowHeight property to Dynamic. That should take care of the issue for you.
<ig:XamGrid RowHeight="Dynamic" ... >