I need to make a function, the mouse events to the parent Widget, so using the setAttribute (Qt: : WA_TransparentForMouseEvents, true);
Code:
MoveWidget_task=new Widget_task;
MoveWidget_task - & gt; The setAttribute (Qt: : WA_TransparentForMouseEvents, true);
Widget_task the inheritance to the Widget, without rewriting the mouse events,
This does not realize my effect, my mouse events didn't preach in the past,
I later in the constructor of Widget_task wrote this code,
Widget_task: : Widget_task (QWidget * parent/*=nullptr */)
: QWidget (parent)
{
This - & gt; The setAttribute (Qt: : WA_TransparentForMouseEvents, true);
}
Thus repaired, can preach the past events, which a great god knows why, what's the setAttribute scope?
CodePudding user response:
I found that I set this property is in MousePress event, is the first piece of code inside theMoveWidget_task=new Widget_task;
MoveWidget_task - & gt; The setAttribute (Qt: : WA_TransparentForMouseEvents, true);
Is inside the Press event, could it be this reason