Questions tagged [qheaderview]

A QHeaderView is a class from the Qt Toolkit which provides a header row or header column for item views.

A QHeaderView displays the headers used in item views such as the QTableView and QTreeView classes. It uses Qt's model/view architecture for consistency with the other item view classes.

The header gets the data for each section from the underlying model. Each header has an orientation and a number of sections. A section refers to a part of the header - either a row or a column, depending on the orientation. The sections can be moved and resized, and can also be hidden and shown.

Each section of a header is described by a specified section ID, and can be located at a particular visual index in the header. A section can have a sort indicator, which indicates whether the items in the associated item view will be sorted in the order given by the section.

For horizontal headers, the section is equivalent to a column in the model, and for vertical headers, the section is equivalent to a row in the model.

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

101 questions
0
votes
1 answer

Remove grey band below QTableView() last row without cell streching?

The solution given at the related question removes the grey band show in the image given. If you change QtWidgets.QHeaderView.Stretch into QtWidgets.QHeaderView.Fixed as done in below script this grey band is back and cells are fixed in either…
ZF007
  • 3,708
  • 8
  • 29
  • 48
0
votes
1 answer

Auto-resize columns of QTableView programmatically

I have a QTableView in my programm which I want to resize automatically. I used the functions headerViewHorizontal->setSectionResizeMode(QHeaderView::ResizeToContents); headerViewHorizontal->setSectionResizeMode(3, QHeaderView::Stretch); to resize…
niaou suzanne
  • 43
  • 1
  • 9
0
votes
0 answers

in Qt5.12 I am trying to get painted horizontal headers to size properly

I have subclassed QHeaderView as a horizontal header and reimplemented its paintSection() method to allow adding a the text e.g. "Axis X1" to the header label. However, all attempts to automatically resize the horizontal headers so that the original…
0
votes
1 answer

Get correct parent in a slot triggered by Button inside a QHeaderView class

Just for a sport of it I am playing around with a demo code from @ekhumoro (all credits for original Qt4 code goes to him), where he inserted a new line of QLineEdit widgets into QHeaderview of QTableView. I ported the code to Qt5 and started to add…
Oak_3260548
  • 1,882
  • 3
  • 23
  • 41
0
votes
1 answer

Painting after hiding a widget get clipped

I am trying to add a QLineEdit to QHeaderView so that I can filter words from QSortFilterProxyModel. At first, header may only show title and a search icon. When user clicks the icon, the QLineEdit opens at the right side, covering the search button…
Vizmuth
  • 9
  • 1
  • 2
0
votes
1 answer

How can I assign different selection modes?

I have default QTableView. I want to get following selection behaviour: If we selecting cells, selection will work like if we accepted SelectionMode::ContiguousSelection If we selecting rows/column by clicking on QHeaderView section, selection…
0
votes
1 answer

Header to a TableView

I've been browsing everywhere and I just cannot find any information on how to create a certain type of header to a TableView in Qt Creator. I want it to look similar to this:
FDREW
  • 13
  • 2
0
votes
1 answer

Mapping a position within a QHeaderView to the context of the scrolled Viewport

I have a QHeaderView that does a few things when clicking either to the left or right of the center of a section header. For this, I need to know the position of the click in relation to the (possibly scrolled) content of the QHeaderView's…
i know nothing
  • 951
  • 1
  • 10
  • 27
0
votes
1 answer

How to create a button beside header text in QTreeView?

I need to create a button beside header text like this for sorting. The requirements are: the button and the header text should be in a group to be aligned together when I click on the button up_arrow, the list will be sorted (in the picture it…
gnase
  • 580
  • 2
  • 10
  • 25
0
votes
0 answers

How to set multiple headers for column in header of QTableWidget?

I am having a QTableWidget and let's say it has 4 columns with headers as Failed DIPS, Failed Outputs, Extra DIPS, Extra Outputs. Now my requirement is that I should categorize the columns i.e to say that I need to add two more headings such as…
Gurushant
  • 952
  • 6
  • 23
0
votes
0 answers

How to set different background colors for each header column of a QTableWidget

I have successfully used the following Qt code in my python application to color horizontal headers in a QTableWidget with distinct background colors: header2 = widget.horizontalHeaderItem(2) purple =…
panofish
  • 7,578
  • 13
  • 55
  • 96
0
votes
0 answers

SetFocus is not working after setting the QHeaderView in QTreeView

Following is the code that I'm using: pHeaderView->setMovable(false); pHeaderView->setClickable(true); pHeaderView->setDefaultAlignment(Qt::AlignCenter); pHeaderView->setTextElideMode(Qt::ElideRight);…
Ankul
  • 53
  • 9
0
votes
1 answer

QTableView horizontalHeaderItem invalid QModelIndex

I have a QTableView and a QSortFilterProxyModel which has a QStandardItemModel as sourcemodel. I'm really desperate because I get an invalid QModelIndex for the following code. Invalid means that column and row of the index is -1 and when I want to…
0
votes
1 answer

Get absolute/global position of table header section while accounting for horizontal scroll

I'm creating a column tracking layout that inherits from QHBoxLayout, which will align a couple of line edits to the table columns: To do that, I calculate the absolute screen position of each section size in ColumnAlignedLayout::setGeometry()…
sashoalm
  • 75,001
  • 122
  • 434
  • 781
0
votes
2 answers

Read model data with custom QHeaderView

I want to set a custom QHeaderView to rotate the horizontal header's text. I'm working with a QStandarItemModel For the moment I've this class QHeaderViewR : public QHeaderView { public: QHeaderViewR():QHeaderView(Qt::Horizontal) {} …
Coyoteazul
  • 123
  • 1
  • 9