Home > Mobile >  Qt button disappeared after using event filters
Qt button disappeared after using event filters

Time:10-03

If (target==UI - & gt; Pb_work) {
If (e - & gt; The type ()==QEvent: : MouseButtonPress) {
Char sendMessage2 []="& lt; Set> . Key_WorkClamp & lt;/var> 1 & lt;/val> \ n ";
The sock - & gt; Write (sendMessage2);
The sock - & gt; Flush ();
ReadServer1 ();
}
If (e - & gt; The type ()==QEvent: : MouseButtonRelease) {
Char sendMessage2 []="& lt; Set> . Key_WorkClamp & lt;/var> 0 & lt;/val> \ n ";
The sock - & gt; Write (sendMessage2);
The sock - & gt; Flush ();
ReadServer1 ();
}
Because of the large buttons, the code is repetitive, so only posted this part,
Also the UI - & gt; Pb_work - & gt; InstallEventFilter (this); Code to run there is no problem, but the interface in the shape of the button can't see, but in the position of button about click, I used to detect the qDebug () is the output, that is to say, function can be achieved, but the button is missing, I tried not UI - & gt; Pb_work - & gt; InstallEventFilter (this), button again,

CodePudding user response:

Post code can't see the problem above, filters and can't see the button, from the two key words to guess because eventfilters inside out of the question, probably paintEvent are filtered out, so I can't draw the button control,
Can stick eventfilters analysis,

CodePudding user response:

May be in the final not return eventfilters
 return QWidget: : eventfilters (target, event); 

CodePudding user response:

Only to filter the mouse events, other events make you lose your
  •  Tags:  
  • Qt
  • Related