Qt 自定义控件使用QDial时,会重复调用paintEvent,导致cpu占用率变高
问题描述
在定义控件中添加QDial,paintEvent一直在调用,导致cpu占用率很高
paintEvent(){
if(rect.width()< 100){
dial->setNotchesVisible(false);
}else
dial->setNotchesVisible(true);
}
解决方法:
不要在paintEvent中使用QDial的setNotchesVisible()方法,该方法会导致控件一直刷新