File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,9 @@ def __init__(self):
5454        self .group_list .customContextMenuRequested .connect (
5555            self .show_group_context_menu )
5656
57+         # 重写鼠标按下事件,阻止右键选中 
58+         self .group_list .mousePressEvent  =  self .group_list_mouse_press_event 
59+ 
5760        # 先创建状态栏 
5861        self .status_label  =  QLabel ("就绪" )
5962        self .status_label .setStyleSheet (
@@ -388,6 +391,15 @@ def close_group(self, name):
388391        self .status_label .setText (
389392            f"🛑 已尝试关闭 { closed_count } { total_enabled }  )
390393
394+     def  group_list_mouse_press_event (self , event ):
395+         """处理组列表鼠标按下事件,阻止右键选中""" 
396+         if  event .button () ==  Qt .RightButton :
397+             # 右键时不调用默认的mousePressEvent,阻止选中行为 
398+             return 
399+         else :
400+             # 左键时正常处理 
401+             QListWidget .mousePressEvent (self .group_list , event )
402+ 
391403    def  show_group_context_menu (self , pos ):
392404        item  =  self .group_list .itemAt (pos )
393405        menu  =  QMenu (self )
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments