qheaderview

QTreeView with fixed column widths

邮差的信 提交于 2019-12-06 13:17:29
问题 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 space. If I enlarge my widget the first column should automatically occupy the need free space, whereas the second and third column should retain their given widths of 50 pixels. This is what I tried so far: main.cpp #include <QApplication> #include

QTreeView with fixed column widths

ⅰ亾dé卋堺 提交于 2019-12-04 19:48:18
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 space. If I enlarge my widget the first column should automatically occupy the need free space, whereas the second and third column should retain their given widths of 50 pixels. This is what I tried so far: main.cpp #include <QApplication> #include <QTreeView> #include <QDebug> #include <QStandardItemModel> #include <QHeaderView> #include

Adding Vertical headers to a QTreeView

核能气质少年 提交于 2019-12-04 12:38:59
I have a QTreeView subclass (and QAbstractItemModel subclass) which has a nice horizontal header. I would like to add vertical headers (going down the left side) to match. But unlike QTableView which has separate vertical ( setVerticalHeader() ) and horizontal headers ( setHorizontalHeader() ), QTreeView only allows a single header ( setHeader() ). I know that I can just pretend that the leftmost column is the header and render it with a different background color (I don't need the ability to resize or rearrange the rows, so I wouldn't have to implement any of those special behaviors). But

Spanning horizontal header in Qt

故事扮演 提交于 2019-12-04 10:41:39
I want to merge(span) horizontal headers in QTableWidget . I tried googling for the same, but no luck and hence posting it. Please guide me. You can subclass QHeaderView and create one section for each of the groups of columns/rows you would like to span and connect signals and slots to have them react to the different columns/rows. The following example is for spanning the horizontal header: #include <QtGui> class MyHeaderModel : public QAbstractItemModel { public: MyHeaderModel(QObject *parent = 0) : QAbstractItemModel(parent) {} int columnCount(const QModelIndex &parent = QModelIndex())

How do I add a header with data to a QTableWidget in Qt?

亡梦爱人 提交于 2019-11-29 08:02:48
I'm still learning Qt and I am indebted to the SO community for providing me with great, very timely answers to my Qt questions. Thank you. I'm quite confused on the idea of adding a header to a QTableWidget . What I'd like to do is have a table that contains information about team members. Each row for a member should contain his first and last name, each in its own cell, an email address in one cell, and office in the other cell. I'd to have a header above these columns to name them as appropriate. I'm trying to start off easy and get just the header to display "Last" (as in last name). Here

How do I add a header with data to a QTableWidget in Qt?

╄→尐↘猪︶ㄣ 提交于 2019-11-28 01:57:25
问题 I'm still learning Qt and I am indebted to the SO community for providing me with great, very timely answers to my Qt questions. Thank you. I'm quite confused on the idea of adding a header to a QTableWidget . What I'd like to do is have a table that contains information about team members. Each row for a member should contain his first and last name, each in its own cell, an email address in one cell, and office in the other cell. I'd to have a header above these columns to name them as

What does QHeaderView::paintSection do such that all I do to the painter before or after is ignored

给你一囗甜甜゛ 提交于 2019-11-28 01:34:18
This question is further development of this post and is different, though may seem similar as this one . I am trying to reimplement QHeaderView::paintSection , so that the background returned from the model would be honored. I tried to do this void Header::paintSection(QPainter * painter, const QRect & rect, int logicalIndex) const { QVariant bg = model()->headerData(logicalIndex, Qt::Horizontal, Qt::BackgroundRole); // try before if(bg.isValid()) // workaround for Qt bug https://bugreports.qt.io/browse/QTBUG-46216 painter->fillRect(rect, bg.value<QBrush>()); QHeaderView::paintSection(painter

How to make a QheaderView multilevel?

≡放荡痞女 提交于 2019-11-26 21:43:29
问题 I am creating an application that saves the data of an object sending service. I created that with Qt , a model of type QStandardItemModel that I want to display with QtableView . But QtableView shows me the line level on the left. I want to delete it or hide it if possible. I also have a problem with a header that I want to divide into two horizontally then divide the corresponding part of the bottom in two vertically. The reason for these division is that I have two headers with similar