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

PyQt Get cell from TableView with header label

I currently load the results of an SQL query into a TableView. self.projectModel = QSqlQueryModel() self.projectModel.setQuery(sql,db) I then need to select a specific cell based on the header label (geometry). This column will move position…
tjmgis
  • 1,589
  • 4
  • 23
  • 42
1
vote
0 answers

QHeaderView::sectionCountChanged how to know which section was added

I wanted to know if there was a way to determine which section was inserted that changed the section count. What I am trying to accomplish is to move the order of newly inserted section to the end. So that newly inserted columns are displayed at the…
MistyD
  • 16,373
  • 40
  • 138
  • 240
1
vote
1 answer

Why won't my custom QHeaderView allow sorting

I implemented my own QHeaderView extending from QHeaderView. After I set sorting enabled on the QTableWidget that uses this view, I still cannot sort. For what it is wroth, the table is initially sorted by the first column. If I do not set the…
jtooker
  • 1,043
  • 1
  • 8
  • 22
1
vote
1 answer

QSortFilterProxyModel breaks columnWidths

What is the standard practice in keeping column widths saved within a QTableView which is having certain columns hidden/removed via a QSortFilterProxyModel (in arbitrary order)? Note that I'm talking about having them hidden and unhidden within a…
kiss-o-matic
  • 1,111
  • 16
  • 32
1
vote
1 answer

QHeaderView::section:selected

I have following style segment applied to QHeaderView QHeaderView::section:selected { padding-left: 16px; background-color: #1c1c1c; } for some reason "selected" Pseudo-State for QHeaderView is not working but in the…
warunanc
  • 2,221
  • 1
  • 23
  • 40
1
vote
1 answer

QHeaderView::mousePressEvent (need to figure out the column/index)

Generally I can get this to work no problem when I reimplement QTableView::mousePressEvent( QMouseEvent* ). However, doing it on QHeaderView is not working for me. Code is simple. void my_header_t::mousePressEvent( QMouseEvent* event ) { if (…
kiss-o-matic
  • 1,111
  • 16
  • 32
1
vote
1 answer

How to calculate QTableView row height. QHeaderView::ResizeToContents for invisible rows/columns

I have QTableView with a little number of rows and about 10 columns. I set QHeaderView::ResizeToContents resizeMode for verticalHeader(). But it works only for visible rows. For example if the tableView is scrolled to right and some data have been…
Funt
  • 399
  • 8
  • 23
0
votes
0 answers

QTableView: Fill 100% or more of the width

I have a QTableView where I use the following code: h_header = self.horizontalHeader() h_header.setSectionResizeMode(QHeaderView.ResizeMode.ResizeToContents) h_header.setStretchLastSection(True) My problem is now that this limits the width of the…
rmweiss
  • 716
  • 1
  • 6
  • 16
0
votes
0 answers

How to reposition custom QHeaderview when QTableWidget is scrolled horizontally

I am using a custom header based on QHeaderView to create column labels that span multiple columns. The column labels are themselves QLabel objects. I can correctly resize the column labels when a column is resized. However, it is unclear how to…
mr_js
  • 949
  • 12
  • 29
0
votes
0 answers

The QHeaderView has a slight vertical offset between the row index and the text in each row

As shown in the figure, there is a slight vertical offset between the row index and the contents of each row. How can I resolve this issue? By the way, how can I make the row index start from 1 instead of 0? class PandasModel(QAbstractTableModel): …
朱海洋
  • 21
  • 4
0
votes
1 answer

Update QHeaderView's model after Drag & Drop

I have a QTableWidget, where Drag & Drop is enabled using the table widget's QHeaderView instance: m_tableWidget->verticalHeader()->setSectionsMovable(true); Also, I have implemented an undo mechanic. Now, I want to implement that a Drag & Drop…
Bakefish
  • 81
  • 6
0
votes
1 answer

When does Qheaderview get its model?

You can access the underlying model of a Headerview with self.model(), but when you use this in the constructor it returns None. For example, this will print 'None' class MyHeaderView(QHeaderView): def __init__(self, orientation, parent): …
mahkitah
  • 562
  • 1
  • 6
  • 19
0
votes
1 answer

QTableWidget's horizontal QHeaderViews are suddenly hidden

I'm working on a project that has a lot of tables. I used QTableWidget. Horizontal headers are visible, verticals are hiddden. I wrote style sheet for one of them, rest of them are just copied from that one. In Qt Designer, everything is alright,…
Abdurahmon
  • 148
  • 1
  • 9
0
votes
1 answer

Add custom header view to table view

I want to create a custom header view and add it to a table view using model. This is my approach: QStandardItemModel * s= new QStandardItemModel(this); s->setHeaderData(0, Qt::Horizontal, "Header 1", Qt::DisplayRole); s->setHeaderData(1,…
mac
  • 105
  • 3
0
votes
1 answer

Last empty column to fill QTableView

In a QTableView I need the last (rightmost) column to be empty, expandable but not movable. The goal is that the table not to suddenly end (for I use alternate color for rows) or to ugly expand to the right. In QHeaderView there is a…