How to select Row in QTableView? - qt

I am new to QT, and I'm using QTableView, as shown below:
On the left side of the table, Qt is automatically showing a row number, as I've noted in red. How do I get rid of these numbers?
My other problem is, if I click any cell, only that cell is selected. How can I make it to where, when a user clicks a cell, the entire row is selected, like I noted in pink? For example, if I click the testApp-copy.itr cell then the entire third row should be selected.

Use
table->verticalHeader()->hide();
to get the vertical header and hide it, and
table->setSelectionBehavior(QAbstractItemView::SelectRows);
to make QTableView only select whole rows.
You may also want to specify the selection mode.

Related

BIRT Column Width not being Respected

I'm trying to create a BIRT report. The code and query side of it works just fine, but the display is rather wonky.
There's one column whose text contents are rather long, and instead of showing some text and allowing scrolling of the text (which is the behavior I'd like there), it simply shows up as a very vertically long text block; kinda ruins the report a bit. I've also tried setting the width on the column, but no dice there either. Any ideas?
Also, as an aside, how do I get the table's columns to have grid lines? I can do that on the rows, but I can't seem to figure out how to do that for the columns. If anyone has insight into that issue, it'd be appreciated.
Here's a screenshot of the issue
Here's my BIRT report XML, without headers and footers in order reduce characters
I think there is no way to use a scrollable view element inside your report, because the output by the default html-emitter is completely static (I would like to see a different answer if this should be wrong).
To your second Question about how to add a border to a column. Click into the cell of your table, click on "Border" inside the "Properties Editor" and select the borders you like to use. This should be repreated for all cells where you want to use the borders, because this configuration is not applied for a whole column but just for one cell. If you want a border for the whole column you need to setup the border for every cell in the column.
If you have already a data cell inside your table cell, you can use the outline view to select the table cell instead of the data cell:

Always have an empty TableRow at the bottom of the TableView

I have a TableView where I add a new row by right clicking on the row below where I want to place the row and choosing "add" in a context menu. This becomes a problem when the TableView has so many rows that the entire view is filled with filled rows, since no empty rows are displayed. When this happens, I can only add a row above the row at the bottom, but not below it.
Adding a "dummy item" to the bottom of the TableView when that is used is not an option. I need to add a TableRow that has a item that is null, like the rows that usually fill out the viewport of the TableView when there's not enough items to fill the viewport.
Is there a way to make sure that there's always a TableRow with no item at the bottom of the table?
Edit: Adding a context menu to the entire TableView and automatically add row at the bottom when that is used is not an option either. This is because I need to add a style class to the row below the input index to provide the user with feedback on where the row will be placed. Therefore there needs to be a TableRow object to add the style class to.
Edit: I realize my text was a little bit messy. Here's an attempt at clarifying the actual behaviour I want:
I don't want the viewport to always display an empty row at the bottom, which would be some kind of "sticky row" behaviour. I want the actual table to display an empty row after the last row. I.e: When I'm in the "middle" of the list, and can't see the last row, no empty row should be displayed. The only time the empty row is needed is when I want to add an item at the end of the table list. Therefore when I scroll down so I see the end of the list, that's when I need an empty row. The reason I need this exact behaviour is explained in the original text.

Selected Item losing Highlight in QTableView

I have a problem with the extendedSelection of my QTableView.
The Problem is that i have some whitespace around my columns and rows and when i click this whitespace the highlighting of my selected Fields is lost.
Its not ocurring when i click somewhere else in my application, only in the whitespace.
Also when i set the selection mode to SingleSelection it works just fine.
here is a short gif to illustrate the problem
https://gyazo.com/8e4ae161aaff25a4afa1b588579ddd01
thank you everyone who can help me
sincerely
Because that white region belongs to QTableWidget, so when you click that place it resets the selection and selected cell is gone since none of cell is selected. But when you click outside of the QTableWidget, selection state still exists.So If you do not want to this, you can increase column widths like this:
ui.tableWidget->setColumnWidth(columnNumber,columnWidht);
or you can decrease the width of QTableWidget to fit the columns. So user can not see and click this white region.

ExtJS Grid Selection

I am new to extjs 4. In my requirement the users selects a cell in a grid, that cell alone need to highlight. Instead of that the whole row has been highlighted. how to fix this issue?
you have to edit css (of row and cell class when hover event occure) based on selecting cell not row selecting.

Highlight selected cell of a flex data grid

I have a flex data grid.I need to highlight the selected cell of the data grid.can u please help me?
AdvancedDataGrid does have a property selectionMode. Change property value single cell or multiple cells, you can select and highlight cells.
DataGrid automatically highlights the selected row (see the examples)
If you're looking for a table-like component, check out Grid or Tile.
It would also help if you would post your source code so that we would know what you are trying to achieve.
I know data grid automatically highlights the selected row.But I'm not searching for row highlight. I'm searching for cell highlight.For example say if I will click on 1st cell of data grid, instead of highlighting the first row it will only highlight the first cell(row-0,col-0)
Thanks!
by setting datagrid property -> selectionMode="singleCell"

Resources