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
2
votes
1 answer

Trouble understanding and handling QHeaderView Signals

I'm currently working on a basic QTGui table to be used for various applications. One feature I want is to be able to double click on a header of a column and call a sort function. I've been looking through the documentation and various posts…
Geeklat
  • 167
  • 1
  • 2
  • 12
2
votes
1 answer

Column sorting not working when using custom HeaderView

I'm trying to create a TableView with sorting functionality. If I set the TableView obj my custom HeaderView, clicking on the header won't sort, even though my custom HeaderView re-implements nothing. If I use instead the TableView's header…
Jason
  • 2,950
  • 2
  • 30
  • 50
2
votes
1 answer

QTreeView with fixed column widths

Today I'm trying to configure a QTreeView to fit my requirements. My view has basically three columns. The second and third column should be exactly 50 pixels wide no matter, what might be widgets size. The first column should occupy the remaining…
Aleph0
  • 5,816
  • 4
  • 29
  • 80
2
votes
1 answer

Qt: QTreeView: center icon on header

For some columns from a QTreeView widget, I use an icon. The icon is set on QVariant headerData (int section, Qt::Orientation orientation, int role) const{ if(role == Qt::DecorationRole) { QIcon icon; if (section == 0) { …
laurapons
  • 971
  • 13
  • 32
2
votes
1 answer

what's wrong with setSectionResizeMode in qt?

I have used qt 5.1.1 for 2 years on Ubuntu. now I install qt 5.5 on it. (I mean both versions are exist on my Ubuntu) actually this version of Qt framework doesn't work as good as the older one. so I want to use qt 5.1.1 . The problem is here that…
s.m
  • 209
  • 2
  • 7
  • 17
2
votes
2 answers

Implement paintSection for QHeaderView delivered class

protected: virtual void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const { QHeaderView::paintSection(painter, rect, logicalIndex); painter->drawRect(2, 2, 10, 10); } Rectangle is not painting. But when…
Ufx
  • 2,595
  • 12
  • 44
  • 83
1
vote
1 answer

Header View title getting overwritten with Inherited controller

I am trying to access the properties and objects that are declared in one view controller in to the page where I need them.Did so by subclassing the view controller.But I have got a problem here,the inherited controller is making the controller…
1
vote
0 answers

QTableView / QTableWidget: Stretch Last Column

How to stretch the last column of a TableView in qml? In C++ with Qt framework it is possible to use setStretchLastSection from QHeaderView but is there a way to do it in qml? EDIT: To be more specific: On the screenshot below, I want the three…
GuillaumeF93
  • 111
  • 1
  • 4
1
vote
0 answers

PyQt sort indicators are not completely visible

I am working with PyQt5. I want to show a sort indicator for my QTableWidget, so I did: table = QTableWidget() table.setSortingEnabled(True) table.horizontalHeader().setSortIndicatorShown(True) I prefer if the sort indicator was on the right of the…
Fooourier
  • 47
  • 5
1
vote
1 answer

What's the difference between two QHeaderView signals?

On Qt doc website in QHeaderView class i found two signals with similar descriptions: void QHeaderView::sectionDoubleClicked(int logicalIndex) and void QHeaderView::sectionHandleDoubleClicked(int logicalIndex) what's the difference between the two…
user10609288
1
vote
1 answer

How to set small column widths in QTreeWidget?

I have a QTreeWidget with two columns and I'm trying to set the second column width to a very small value. If I set the width to over 35 it will resize correctly. However if I try to set the width below 35 it will always end up at 35. Interesting…
1
vote
1 answer

QTableWidget: Row does not size properly

I am implementing a small example using a QTableWidget with specific headers. However, as soon as I run the example the rows do not stretch properly as it is possible to see in the following example (which is the wrong behavior): After manual…
Emanuele
  • 2,194
  • 6
  • 32
  • 71
1
vote
1 answer

Create a DB Browser style QHeaderview in PyQt5

I would like to create a QHeaderView in PyQt5 like the one that is used in this project (DB Browser for SQLite). The problem is that I don't know C++ and I don't understand how the classes and widgets are created from the source code that is on…
amunozo
  • 57
  • 7
1
vote
1 answer

Customizing QHeaderView resize handle

I use the cleanlooks style for my application which fits best the look and feel I want. The annoying thing a stumbled on is that the QHeaderView (horizontal header of a QTableWidget for instance) doesn't paint the resize handle between sections when…
Jeannot
  • 1,165
  • 7
  • 18
1
vote
1 answer

QTableView columns - can't set small width

I have two QTableView with own simple models. After making the following: tv1->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); tv1->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch); …
Greadimar
  • 81
  • 8