Controlling width/layout in CListCtrl (Icon view) - mfc

Apart from the fact I still can't see why this class fills columns and scrolls horizontally, rather than filling rows and scrolling vertically, I'm confused how the width of items is controlled. I'm seeing quite a lot of padding (50-80 pixels) between the longest item in a column and the next column which means wasted space.
Is it controllable?

Somebody else asked about scrolling, here is the answer.
If you are referring to column width then you can change it using:
CListCtrl list;
list.InsertColumn(0, _T("Column1"));
list.InsertItem(0, _T("Item with a long name"));
list.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);

Related

Qt scrollbar pushes table inwards?

I have made a window in Qt C++ where inside I fill a table with items row by row. However, after I fill out enough rows, a scrollbar appears in order to allow me to scroll the extra rows. The problem is - when the scrollbar appears, it squeezes the table inwards. Is there some way to prevent this from happening?

CListCtrl: single column without column headings?

If I set View = Report, then you get a single column and a vertical scrollbar (what I want). However you also get an area at the top reserved for column headings even if you don't have column headings (not what I want).
If I set View = List, then no screen space wasted for column headings (what I want) but there are now multiple columns and a horizontal scrollbar (not what I want).
I think I'd be happy if I could use Report mode but just somehow shrink the space reserved for the column headings to zero. Any ideas?
I think you are searching for CListBox. See here for more.
If you would like to continue with CListCtrl then use List view or Small Icon instead of Report view. For more see here.

QTableWidget show scroll bar

I would like the horizontal scroll bar to appear whenever there is text eliding. Such that the user won't have to resize the whole GUI. How would I do this?
This is what I have coded:
ui->tableWidget->horizontalHeader()->setStretchLastSection(true);
ui->tableWidget->horizontalHeader()->setSectionResizeMode(1,QHeaderView::Stretch);
ui->tableWidget->resizeColumnsToContents();
I also tried enabling scrollbar to appear always, but scrolling to the very right doesn't do anything.
If I set textElideMode to ElideNone , the text from the 2nd column is partially hidden and no scrollbar appears.
QHeaderView::Stretch will stretch the column width to the available space. Use QHeaderView::ResizeToContents to make the column wide enough to display the content, resulting in a horizontal scroll bar if necessary.
This will have a couple of side effects of which I'm not sure you want them.
There will probably be no more ellipsis in the elided text.
If all of the values in your Hash column are very small, then that column will be very thin, so there might be 'empty' space next to that column.

QTableWidget resize column both on content and stretch

So, with
tableWibget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
my column are resized to content, but that doesn't look good when content is small and grid doesn't fit all the space.
and with
tableWibget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
it fits all the space, but sometimes content of some cell doesn't shown fully.
how can I make something like both above - content must fit all the place in widget, but if some cell can't take all content it resize to fit it all and scroll bar appears
You can set resize mode on column index as below::
headerView->SetResizeMode(0, QHeaderview::Stretch);
headerView->SetResizeMode(1,QHeaderview::Interactive);

CGrigCtrl horizontal scrolling

How to enable horizontal scrollbar smooth scrolling for CGridCtrl. Now it jumps by fields when I scroll it from left to right.
I assume you're talking about CGridCtrl published in this CodeProject article.
If so, then you're going to have to completely override the drawing methods to offset the columns by the current scroll position (instead of calculating the first column to display from the scroll position).
To get you started, you should begin by looking at GetScrollPos(SB_HORZ) to use as an offset to begin drawing.