I’m using QTCreator and I created a QWidget, then I have hidden the title bar with setWindowFlags(Qt::CustomizeWindowHint);.
But I can’t select or move my widget. How can I use the mouseEvent to solve that?
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.
If you want to be able to move your window around on your screen by just clicking and dragging (while maintaining the mouse button pressed), here’s an easy way to do that:
In
mousePressEvent, you save the global (screen-coordinate) position of where the mouse was, and then in themouseMoveEvent, you calculate how far the mouse moved and update the widget’s position by that amount.Note that if you have enabled mouse tracking, you’ll need to add more logic to only move the window when a mouse button is actually pressed. (With mouse tracking disabled, which is the default,
mouseMoveEvents are only generated when a button is held down).