Continue with my last post about QtableView tutorial (fill Qtableview with value), I try to create another post about how to create contextmenu in QtableView. With this tutorial, you can implementated contextmenu in other Widget in Qt like QtableWidget, QlistWidget and other. The basic idea how to create contextmenu in QtableView is like with contextmenu in QtableWidget, contextmenu in Qlistwidget and other.
We can add contextmenu in widget with change setContextMenuPolicy property with value Qt::CustomContextMenu. We can set contextmenu in QtableView with command :