Clicking on the header changes the row selected. So if I have row five selected, and I click a column in the header, the top row visible becomes selected. No sorting or anything.

I don't want this.

Also, I have connected the QTableView clicked signal to a function, and clicking on the header seems to make that signal fire. I also don't want this.

I want clicking on the header to NOT change the selected row, and also to NOT cause QTableView to fire its clicked signal.

How can I achieve this?

]]>https://forum.qt.io/topic/78686/clicking-header-of-qtableview-selects-top-row-and-causes-qtableview-to-emit-clickedRSS for NodeSat, 25 May 2019 13:37:04 GMTThu, 27 Apr 2017 14:34:00 GMT60I have a QTableView. It has a header. I'm stuck using QT 4.something

Clicking on the header changes the row selected. So if I have row five selected, and I click a column in the header, the top row visible becomes selected. No sorting or anything.

I don't want this.

Also, I have connected the QTableView clicked signal to a function, and clicking on the header seems to make that signal fire. I also don't want this.

I want clicking on the header to NOT change the selected row, and also to NOT cause QTableView to fire its clicked signal.

How can I achieve this?

]]>https://forum.qt.io/post/390299https://forum.qt.io/post/390299Thu, 27 Apr 2017 14:34:00 GMTTwo questions for you: have you called setSortingEnabled on your table? And are you using setHeaderData to set the role of the header to Qt::DisplayRole?
]]>https://forum.qt.io/post/390303https://forum.qt.io/post/390303Thu, 27 Apr 2017 15:12:22 GMTA little unfortunately, I'm maintaining some code in which what I'm working with is a view inherited from QTableView, and a header inherited from QHeaderView.

That said, I think the answer to your first question must be yes, because I spent some time fixing sorting earlier and it does sort (i.e. click header section, and the rows rearrange themselves).

The second; I do not know. I am looking.... The header sections have words in them, so something must be setting that.

However, I don't understand what you mean by "set the role of the header to Qt::DisplayRole". I thought that Qt::DisplayRole was the role of various data; I don't understand how an entire header's role can be Qt::DisplayRole.