I need to create a context menu on right clicking at my window. But I really don’t know how to achieve that.
Are there any widgets for that, or I have to create it from the beginning?
Programming language: Python
Graphical lib: Qt (PyQt)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I can’t speak for python, but it’s fairly easy in C++.
first after creating the widget you set the policy:
then you connect the context menu event to a slot:
Finally, you implement the slot:
that’s how you do it in c++ , shouldn’t be too different in the python API.
EDIT: after looking around on google, here’s the setup portion of my example in python: