Piotr Byzia
Piotr Byzia

Reputation: 3423

How to enable context menu on a VerticalHeaderItem inside a QTableWidget?

I have QTable widget, where I set

setVerticalHeaderItem(0, QTableWidgetItem("some header", 0))

I set a contex menu by

setContextMenuPolicy(Qt.ActionsContextMenu)

and it works fine on my table's elements other than 1st column, i.e. a VerticalHeaderItem. Basically, when I right-click on 1st column item a context menu doesn't pop up, while clicking on any other elements >1st column causes the context menu to pop up (populated with the QActions I defined, not shown here for clarity).

Is there any attribute I should set in order to make 1st (VerticalHeaderItem) column react to right-click? Qt.ItemFlags maybe? If so, could anyone write a code snippet how to set it properly? Preferably in Python, but C++ would be also OK.

My conf: QT 4.5.2, PyQT 4.5.4, under Windows XP SP2.

Upvotes: 1

Views: 2026

Answers (1)

Lukáš Lalinský
Lukáš Lalinský

Reputation: 41306

The headers are widgets on their own. So, set the context menu policy on myTableWidget.verticalHeader().

Upvotes: 3

Related Questions