[PyQt] Getting mouse and key event with a qtablewidget

James Emerton ephelon at gmail.com
Thu Mar 15 16:31:39 GMT 2007


There are two methods to accomplish this:

1.  Subclass QTable and reimplement contentsKeyPressEvent() and
contentsContextMenuEvent()

2.  Add an eventFilter to the viewport of your table.

Of the two methods, the first is generally preferred.  Have a look at
the Qt docs for more.

James


On 3/15/07, duncan duncan <duncan73 at gmail.com> wrote:
> Hello.
>
> I'd like to be able to process the mouse and key pressed event with a
> qtablewidget
> The goal is to have a table in which the number of rows and columns are
> dinamically
> created when certain keys are pressed and that had a context menu to delete
> the
> row/column.
>
> An example can be: if I press the tab key on the last column, a column is
> added to the table or if I press the
> arrow down on the last row, a new row is added.
>
> Any hints ?
>
> thaks
>  Gianluca
>
>
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>


More information about the PyQt mailing list