Re: Question on Context Menu
Quote:
Originally Posted by Sarol
1) Once I right on the QTableWidget the menu appears where the mouse cursor is, but will not disappear until another click ( left/right ) is detected. Is there a way to hide the menu once the cursor is no longer on top of it, or moves a certain distance away? ( I thought I saw a post on this once before, but am having trouble locating it to see if it helps with my issue )
One of the ways to do, Install a event filter on the QTableWidget, which captures the mouse move event and check if mouse is not over context menu then hide / delete the menu, you can also install the filter on context menu itself
Quote:
Originally Posted by Sarol
2) Is there a way to prevent the context menu from displaying on empty rows? My general thought is to do something with the cursor position and check where it is in relation to the table, and then see if there is a valid row at that particular point. However, I am unsure of how to really do this.
Code:
void QTMainform::contextMenuRequested( const QPoint& point )
{
...
if(item != 0)
{
if(!item->text().isEmpty())
{
//Then Show Context Menu
...
}
}
...
}
Re: Question on Context Menu
Santosh,
Thank you very much for the response. I was able to solve the second question with your help.
As for my first issue, I have not dealt with Event Filters before, so I will have to research these and then implement your suggestion.
Have a great day,
Sarol