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
1
vote
1 answer

Get header section text in QHeaderView

I am subclassing a QHeaderView within a QTableWidget to provide custom functionality for hiding/showing sections. Is there a way to get the text of a section from within the header view? I know I can do this from within the scope of the table, but…
Spencer
  • 1,931
  • 1
  • 21
  • 44
1
vote
1 answer

how to add QLabel object to qheaderview?

need to add subscript to horizontal header of QTableWidget with QLabel where html will be the text of the QLabel.
1
vote
1 answer

Prevent TableView header from being highlighted

I am working with a table view where in I can select a row and it will open a new window after a double click. However, I don't want the header to be highlighted whenever I am clicking something on its…
Tenserflu
  • 520
  • 5
  • 20
1
vote
2 answers

How to disable auto gradient effect in QHeaderView?

I have type some code to fill the whole QTreeWidget with single color: myTree->setStyleSheet("border: 1px solid green; background: green;"); But as a result, the header color is not a solid color. Instead, the header has a gradient with two…
Arseniy
  • 266
  • 2
  • 14
1
vote
1 answer

Disallow column from getting moved to index 0?

Is there a way to allow QTableView sections (columns) to be reordered (aka setSectionsMovable(true)) but disallow any of the columns from being moved to index 0? I'd like to make it so that columns can be reordered by dragging them, but NOT allow…
earth
  • 945
  • 1
  • 10
  • 27
1
vote
1 answer

QStandardItemModel with multiple headers - decouple QTreeView header from model

I have a QStandardItemModel that needs different horizontal header labels in different views. I'm having trouble finding information about how to decouple the header of a QTreeView from the model in that way. Is this possible? See a simple code…
1
vote
2 answers

Qt: QHeaderView place sort-indicator on the right of the header text

If I set: QHeaderView::down-arrow { subcontrol-position: center left}, the down-arrow is on the left of the column, and if I set center right, it is placed on the right of the column, but I want to place the arrow next to the title (on the right…
laurapons
  • 971
  • 13
  • 32
1
vote
1 answer

How to display bold text in a specific QHeaderView section in combination with a stylesheet

I'm using application-wide stylesheets to alter my QTableView's look. At the same time, I want certain column headers to have bold text, depending on the header text. For this I derived from QHeaderView and implemented the paintSection…
i know nothing
  • 951
  • 1
  • 10
  • 27
1
vote
1 answer

QComboBox in the header of a QTableview

I'd like to create a QCombobox in the header of a column of a QTableview. Any ideas to do this? Thanks
PinTxO
  • 61
  • 9
1
vote
2 answers

QHeaderView style each column

I am trying to edit style of the header of a QTreeWidget. I found that I can edit it with QHeaderView::section and there, edit background, colors, border... However, I would like to edit specifically columns headers separately. I found on the…
Manu310
  • 158
  • 2
  • 12
1
vote
0 answers

Resizing QHeaderView columns when the widget's width changes, while still letting the user resize column widths

I want the user to be able to resize the columns manually,including being able to move columns behind the view's borders, but when the view resizes I want the columns to resize proportionally. Is there any neater decision than installing resizeEvent…
Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335
1
vote
3 answers

Add custom widgets as QTableWidget HorizontalHeader

Is it possible to display a custom QWidget on the QHeaderView instead of just the generic string? Also, is it possible to change the height of the horizontalHeaderItem only? It crashes when I do…
BurninatorDor
  • 1,009
  • 5
  • 19
  • 42
1
vote
0 answers

Setting a dynamic tooltip for QHeaderView item

I want to have a dynamic tooltip for one of my header items of a QtableView. The content of the tooltip changes with alt key press. I found some code related to using delegates in the following site: Tooltips for truncated items in a QTreeView In…
sajas
  • 1,599
  • 1
  • 17
  • 39
1
vote
1 answer

How to draw text in derived from QHeaderView class

I need to draw text in derived from QHeaderView class. But this code does not work. void HeaderView::paintSection(QPainter *painter, const QRect &, int) const { painter->drawText(0, 0, "abcde"); }
Ufx
  • 2,595
  • 12
  • 44
  • 83
1
vote
2 answers

Updating sort-order indicator in QTableView/QHeaderView when model is sorted

I want to know how to ensure the sort indicator in the horizontal header of a QTableView is updated when a programmatic sort is performed on the model. Here's the problem: QStandardItemModel model(3,1); QTableView view; view.setModel( &model ); //…
SimonD
  • 638
  • 5
  • 16